📄 sendasexampleengine.cpp
字号:
/**
*
* @brief Definition of CSendAs ExampleApplication
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*/
// Class include
#include "SendAsExampleEngine.h"
// System includes
#include <MsgBioUids.h> // KMsgBioUidPictureMsg
#include <mtmdef.h> // KMsvMessagePartNone
#include <mtmuids.h> // KUidMtmQuerySupportAttachments
#include <AknUtils.h>
// User includes
#include "sendasexample.hrh"
// Attachment filename
_LIT(KAttachmentFilename, "\\system\\apps\\SendAsExample\\penguins.jpg");
CSendAsExampleEngine* CSendAsExampleEngine::NewL(MSendAsExampleEngineObserver& aObserver)
{
CSendAsExampleEngine* self = new (ELeave) CSendAsExampleEngine(aObserver);
CleanupStack::PushL(self);
self->ConstructL();
CleanupStack::Pop(self);
return self;
}
CSendAsExampleEngine::CSendAsExampleEngine(MSendAsExampleEngineObserver& aObserver)
: CActive(0),
iObserver(aObserver)
{
}
void CSendAsExampleEngine::ConstructL()
{
CActiveScheduler::Add(this);
// Construct and initialise the SendAs object
ResetL();
}
CSendAsExampleEngine::~CSendAsExampleEngine()
{
Cancel();
delete iSendAs;
}
void CSendAsExampleEngine::CreateMessageL(TInt aMtmIndex, const TDesC& aAddress)
{
// Set the MTM
iSendAs->SetMtmL(aMtmIndex);
// Create the message
iSendAs->CreateMessageL();
iSendAs->AddRecipientL(aAddress); // Does this cause trouble for IR & BT?
// Add an attachment
TMsvId attachmentId;
TFileName filename(KAttachmentFilename);
User::LeaveIfError (CompleteWithAppPath (filename));
iSendAs->CreateAttachmentL(attachmentId, filename);
// iSendAs->SetBioTypeL(KMsgBioUidPictureMsg);
// Validate the message
TMsvPartList msgFailParts = iSendAs->ValidateMessage();
if (msgFailParts == KMsvMessagePartNone)
{
iSendAs->SaveMessageL(iStatus);
SetActive();
}
else
{
iObserver.HandleSaveMessageCompleteL(KErrCorrupt);
iSendAs->AbandonMessage();
ResetL();
}
}
void CSendAsExampleEngine::ResetL()
{
delete iSendAs;
iSendAs = NULL;
iSendAs = CSendAs::NewL(*this);
iSendAs->AddMtmCapabilityL(KUidMtmQuerySupportAttachments);
}
TBool CSendAsExampleEngine::CapabilityOK(TUid /*aCapabilty*/, TInt /*aResponse*/)
{
return ETrue;
}
void CSendAsExampleEngine::RunL()
{
iObserver.HandleSaveMessageCompleteL(iStatus.Int());
}
void CSendAsExampleEngine::DoCancel()
{
if (iSendAs)
{
iSendAs->Cancel();
}
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -