📄 irserialappui.cpp
字号:
/**
*
* @brief Definition of CIrSerialAppUi
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*/
// INCLUDE FILES
// Class include
#include "IrSerialAppUi.h"
#include "IrSerialEngine.h"
// System includes
#include <IrSerial.rsg> // R_IRSERIAL_DIALOG
#include <stringloader.h> // StringLoader
#include <aknnotewrappers.h> // Note Dialogs
#include <eikmenup.h> // CEikMenuPane
// User includes
#include "IrSerialDialog.h" // CInfraredExampleDialog
#include "IrSerial.hrh" // commands
// ================= MEMBER FUNCTIONS =======================
/**
* Symbian OS 2nd phase constructor. Constructs and executes the application's dialog,
* setting itself as the dialog's MOP parent, and adds it to the control
* stack. Also instantiate the infrared engine (active object).
*/
void CIrSerialAppUi::ConstructL()
{
BaseConstructL();
iAppDialog = new (ELeave) CIrSerialDialog;
iAppDialog->SetMopParent(this);
iAppDialog->ExecuteLD(R_IRSERIAL_DIALOG);
AddToStackL(iAppDialog);
iEditOption = ETrue;
iInfraredEngine = CIrSerialEngine::NewL(CActive::EPriorityStandard, this);
}
/**
* Destructor.
* Removes the application's dialog from the stack and deletes it.
* Remove the Infrared active object.
*/
CIrSerialAppUi::~CIrSerialAppUi()
{
if (iAppDialog)
{
RemoveFromStack(iAppDialog);
delete iAppDialog;
}
delete iInfraredEngine;
}
/**
* From CEikAppUi, takes care of command handling.
*
* @param aCommand command to be handled
*/
void CIrSerialAppUi::HandleCommandL(TInt aCommand)
{
switch (aCommand)
{
case EIrSerialCmdSendIr: // Send text via IR
{
iAppDialog->SetEditableL(EFalse); // Change text control to view mode
iEditOption = EFalse;
// Get pointer to the text control and use it to retrieve the entered text and
// initilaise the TBuf with the text
CCoeControl* textControl = iAppDialog->Control(EIrSerialFormText);
CEikEdwin* textEdwin = static_cast<CEikEdwin*>(textControl);
TBuf<EIrSerialFormEdwinMaxLength> textData(NULL);
textEdwin->GetText(textData);
// Initialise the active object and then open the serial port. Asynchronously transmit data.
iInfraredEngine->InitialiseL();
iInfraredEngine->OpenL();
iInfraredEngine->Transmit(textData);
break;
}
case EIrSerialCmdEdit: // Edit the text control
{
iAppDialog->SetEditableL(ETrue);
iEditOption = ETrue;
break;
}
case EEikCmdExit:
{
Exit();
break;
}
default:
break;
}
}
/**
* Dynamically initialise menu panes
* @param aResourceId id of the resource passed
* @param aMenuPane handle to the menu pane being initialised
*/
void CIrSerialAppUi::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
{
if (aResourceId == R_IRSERIAL_MENU_PANE)
{
aMenuPane->SetItemDimmed (EIrSerialCmdEdit, iEditOption);
}
MEikMenuObserver::DynInitMenuPaneL (aResourceId, aMenuPane);
}
/**
* Constructs and displays information note to indicate printing result
* @param result which contains error return code
*/
void CIrSerialAppUi::PrintResultDialogL(TInt result)
{
if(result == KErrNone)
{
HBufC* okText;
okText = StringLoader::LoadLC(R_IR_EXAMPLE2_OK);
CAknConfirmationNote* note = new (ELeave) CAknConfirmationNote;
note->ExecuteLD(okText->Des());
CleanupStack::PopAndDestroy(okText);
}
else if(result == KErrInUse)
{
HBufC* inUseText;
inUseText = StringLoader::LoadLC(R_IR_EXAMPLE2_IN_USE);
CAknWarningNote* note = new (ELeave) CAknWarningNote;
note->ExecuteLD(inUseText->Des());
CleanupStack::PopAndDestroy(inUseText);
}
else if(result == KErrTimedOut)
{
HBufC* timeoutText;
timeoutText = StringLoader::LoadLC(R_IR_EXAMPLE2_TIMEOUT);
CAknWarningNote* note = new (ELeave) CAknWarningNote;
note->ExecuteLD(timeoutText->Des());
CleanupStack::PopAndDestroy(timeoutText);
}
else
{
HBufC* errorText;
errorText = StringLoader::LoadLC(R_IR_EXAMPLE2_ERROR);
CAknWarningNote* note = new (ELeave) CAknWarningNote;
note->ExecuteLD(errorText->Des());
CleanupStack::PopAndDestroy(errorText);
}
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -