📄 systemagentdocument.cpp
字号:
/**
*
* @brief Definition of CSystemAgentDocument
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*/
// INCLUDE FILES
// Class include
#include "SystemAgentDocument.h"
// User includes
#include "SystemAgentAppUi.h" // CSystemAgentAppUi
// ================= MEMBER FUNCTIONS =======================
/**
* Constructs the document for aApp
*
* @param aApp for which the document is constructed
*/
CSystemAgentDocument::CSystemAgentDocument(CEikApplication& aApp)
:CAknDocument(aApp),
iSystemAgentState(ESystemAgentRed)
{
}
/**
* Symbian OS 2nd phase constructor.
*
*/
void CSystemAgentDocument::ConstructL()
{
// Connect to the System Agent
User::LeaveIfError(iSAVarChangeNotify.Connect());
// Set initial value for our state and notify System Agent of it
SetSystemAgentStateVarL(ESystemAgentRed);
}
/**
* Symbian OS 2nd phase constructor.
* Constructs the CSystemAgentDocument using the constructor and the ConstructL
* method.
* @param aApp for which the CSystemAgentDocument is constructed
* @return The newly constructed CSystemAgentDocument
*/
CSystemAgentDocument* CSystemAgentDocument::NewL(CEikApplication& aApp)
{
CSystemAgentDocument* self = new (ELeave) CSystemAgentDocument(aApp);
CleanupStack::PushL(self);
self->ConstructL();
CleanupStack::Pop(self);
return self;
}
/**
* Destructor.
* Releases our state variable and closes the connection to the System Agent.
*/
CSystemAgentDocument::~CSystemAgentDocument()
{
iSAVarChangeNotify.ReleaseVariable(KUidSystemAgentStateVariable);
iSAVarChangeNotify.Close();
}
/**
* Creates the AppUi for this document.
* @return The newly constructed AppUi
*/
CEikAppUi* CSystemAgentDocument::CreateAppUiL()
{
return new (ELeave) CSystemAgentAppUi;
}
/**
* Demonstrates notifying the System Agent of a change in a state variable
*/
void CSystemAgentDocument::SetSystemAgentStateVarL(TSystemAgentStatus aState)
{
// Update our internal state and notify the System Agent that our state has changed
iSystemAgentState = aState;
iSAVarChangeNotify.NotifySaVarChangeL(KUidSystemAgentStateVariable, iSystemAgentState);
}
/**
* Simply changes our state to a different value
*/
void CSystemAgentDocument::ChangeSystemAgentStateVarL()
{
// Change our state to a different color
TSystemAgentStatus newState = ESystemAgentRed;
if (iSystemAgentState == ESystemAgentRed)
{
newState = ESystemAgentGreen;
}
else if (iSystemAgentState == ESystemAgentGreen)
{
newState = ESystemAgentBlue;
}
else if (iSystemAgentState == ESystemAgentBlue)
{
newState = ESystemAgentRed;
}
SetSystemAgentStateVarL(newState);
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -