📄 sendasexampleappui.cpp
字号:
/**
*
* @brief Definition of CSendAs ExampleApplication
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*/
// INCLUDE FILES
#include "SendAsExampleAppUi.h"
#include <aknnotewrappers.h> // CAknInformationNote
#include <avkon.hrh>
#include <eikmenup.h> // CEikMenuPane
#include <SendAsExample.rsg>
#include "SendAsExampleContainer.h"
#include "SendAsExampleEngine.h"
#include "SendAsExample.hrh"
// String literals
_LIT(KErrorSendFailed, "Message save failed");
_LIT(KConfMessageSaved, "Message saved to drafts");
// ================= MEMBER FUNCTIONS =======================
//
// ----------------------------------------------------------
// CSendAsExampleAppUi::ConstructL()
// ?implementation_description
// ----------------------------------------------------------
//
void CSendAsExampleAppUi::ConstructL()
{
BaseConstructL();
iAppContainer = new (ELeave) CSendAsExampleContainer;
iAppContainer->SetMopParent(this);
iAppContainer->ConstructL( ClientRect() );
AddToStackL( iAppContainer );
// Construct the SendAs object
iEngine = CSendAsExampleEngine::NewL(*this);
}
// ----------------------------------------------------
// CSendAsExampleAppUi::~CSendAsExampleAppUi()
// Destructor
// Frees reserved resources
// ----------------------------------------------------
//
CSendAsExampleAppUi::~CSendAsExampleAppUi()
{
if (iAppContainer)
{
RemoveFromStack( iAppContainer );
delete iAppContainer;
}
delete iEngine;
}
// ------------------------------------------------------------------------------
// CSendAsExampleAppUi::::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
// This function is called by the EIKON framework just before it displays
// a menu pane. Its default implementation is empty, and by overriding it,
// the application can set the state of menu items dynamically according
// to the state of application data.
// ------------------------------------------------------------------------------
//
void CSendAsExampleAppUi::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
{
if (aResourceId == R_SENDASEXAMPLE_SEND_SUBMENU)
{
const CDesCArray& mtms = iEngine->AvailableMtms();
const TInt count = mtms.Count();
if (count == 0)
return;
aMenuPane->SetItemDimmed(ESendAsExampleCmdDummy, ETrue);
TInt commandId = ESendAsExampleCmdMtmBase;
CEikMenuPaneItem::SData data;
data.iCascadeId = 0;
data.iFlags = 0;
for (TInt i = 0; i < count; i++)
{
data.iCommandId = ++commandId;
data.iText = mtms[i];
aMenuPane->AddMenuItemL(data);
}
iMaxMtmCmdId = commandId;
}
}
// ----------------------------------------------------
// CSendAsExampleAppUi::HandleKeyEventL(
// const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
// ?implementation_description
// ----------------------------------------------------
//
TKeyResponse CSendAsExampleAppUi::HandleKeyEventL(const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/)
{
return EKeyWasNotConsumed;
}
// ----------------------------------------------------
// CSendAsExampleAppUi::HandleCommandL(TInt aCommand)
// ?implementation_description
// ----------------------------------------------------
//
void CSendAsExampleAppUi::HandleCommandL(TInt aCommand)
{
switch (aCommand)
{
case EAknSoftkeyBack:
case EEikCmdExit:
{
Exit();
break;
}
// Handle dynamic command IDs allocated to MTM list
default:
if (aCommand > ESendAsExampleCmdMtmBase && aCommand <= iMaxMtmCmdId)
{
const TInt index = (aCommand - ESendAsExampleCmdMtmBase) - 1;
// Get an address
TBuf<ESendAsExampleMaxAddressLength> address;
CAknTextQueryDialog* dlg = new (ELeave) CAknTextQueryDialog(address, CAknQueryDialog::ENoTone);
TInt ret = dlg->ExecuteLD(R_SENDASEXAMPLE_ADDRESS_QUERY);
if (ret == EAknSoftkeyOk)
iEngine->CreateMessageL(index, address);
}
break;
}
// Reset iMaxMtmCmdId
iMaxMtmCmdId = ESendAsExampleCmdMtmBase;
}
void CSendAsExampleAppUi::HandleSaveMessageCompleteL(TInt aError)
{
if (aError == KErrNone)
{
CAknInformationNote* note = new (ELeave) CAknInformationNote;
note->ExecuteLD(KConfMessageSaved);
}
else
{
CAknErrorNote* note = new (ELeave) CAknErrorNote;
note->ExecuteLD(KErrorSendFailed);
}
iEngine->ResetL();
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -