📄 mtmsexampleappui.cpp
字号:
/*
============================================================================
Name : MtmsExampleAppUi.cpp
Author : Lion
Copyright : Your copyright notice
Description : CMtmsExampleAppUi implementation
============================================================================
*/
// Class include
#include "MtmsExampleAppUi.h"
// System includes
#include <aknnotewrappers.h> // CAknErrorNote, CAknInformationNote
#include <MtmsExample.rsg>
// User includes
#include "MtmsExampleDialog.h" // CMtmsExampleDialog
#include "MtmsExampleEngine.h" // CMtmsExampleEngine
#include "MtmsExample.hrh" // commands
_LIT(KInvalidMessage, "Message is invalid");
_LIT(KMessageSent, "Message sent!");
_LIT(KMessageUnsent, "Message unsent: %d");
// ================= 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.
*/
void CMtmsExampleAppUi::ConstructL()
{
BaseConstructL();
// Create engine
iEngine = CMtmsExampleEngine::NewL(*this);
iAppDialog = new (ELeave) CMtmsExampleDialog;
iAppDialog->SetMopParent(this);
iAppDialog->ExecuteLD(R_MTMS_EXAMPLE_DIALOG);
AddToStackL(iAppDialog);
}
/**
* Destructor.
* Removes the application's dialog from the stack and deletes it.
*/
CMtmsExampleAppUi::~CMtmsExampleAppUi()
{
delete iEngine;
if (iAppDialog)
{
RemoveFromStack(iAppDialog);
delete iAppDialog;
}
}
/**
* From CEikAppUi, takes care of command handling.
*
* @param aCommand command to be handled
*/
void CMtmsExampleAppUi::HandleCommandL(TInt aCommand)
{
if (!iEngine->IsReady())
return;
switch (aCommand)
{
case EMtmsExampleCmdSendSMS:
if (!GetAddressL())
{
break;
}
iEngine->CreateDraftSMSL(iAddress);
if (!iEngine->ValidateSMS())
{
NotifyMessageInvalidL();
}
else
{
iEngine->SendSMSL();
iAppDialog->DrawDeferred();
}
break;
case EMtmsExampleCmdSendMMS:
if (!GetAddressL())
{
break;
}
iEngine->CreateDraftMMSL(iAddress);
if (!iEngine->ValidateMMS())
{
NotifyMessageInvalidL();
}
else
{
iEngine->SendMMSL();
}
break;
case EEikCmdExit:
Exit();
break;
default:
break;
}
}
void CMtmsExampleAppUi::NotifyMessageInvalidL()
{
CAknErrorNote* note = new (ELeave) CAknErrorNote;
note->ExecuteLD(KInvalidMessage);
}
TInt CMtmsExampleAppUi::GetAddressL()
{
CAknTextQueryDialog* dlg = new (ELeave) CAknTextQueryDialog(iAddress, CAknQueryDialog::ENoTone);
return dlg->ExecuteLD(R_MTMS_EXAMPLE_ADDRESS_QUERY);
}
void CMtmsExampleAppUi::HandleMessageSentL(TInt aError)
{
if (aError == KErrNone)
{
CAknInformationNote* note = new (ELeave) CAknInformationNote;
note->ExecuteLD(KMessageSent);
}
else
{
TBuf<64> buf;
buf.Format(KMessageUnsent, aError);
CAknErrorNote* note = new (ELeave) CAknErrorNote;
note->ExecuteLD(buf);
}
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -