📄 writesmsview.cpp
字号:
/*
* ============================================================================
* Name : CWriteSmsView from CAknView
* Part of : WriteSms
* Copyright (c) 2003 Nokia. All rights reserved.
* ============================================================================
*/
// INCLUDE FILES
#include <aknviewappui.h>
#include <avkon.hrh>
#include <aknnotewrappers.h>
#include <HelperGenius.rsg>
#include "HelperGenius.hrh"
#include "WriteSmsView.h"
#include "smsview.h"
#include "WriteSmsContainer.h"
#include <akncontext.h> //for CAknContextPane
#include <akntitle.h> //for CAknTitlePane
#include "HelperGeniusAppUi.h"
#include <HelperGenius.mbg> //for mbm
#include "MtmsExampleEngine.h"
_LIT(KInvalidMessage, "Message is invalid");
_LIT(KMessageSent, "Message sent!");
_LIT(KMessageUnsent, "Message unsent: %d");
// ================= MEMBER WriteSmsS =======================
// C++ default constructor can NOT contain any code, that
// might leave.
//
CWriteSmsView* CWriteSmsView::NewL()
{
CWriteSmsView* self = NewLC();
CleanupStack::Pop(self);
return self;
}
CWriteSmsView* CWriteSmsView::NewLC()
{
CWriteSmsView* self = new (ELeave) CWriteSmsView;
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
CWriteSmsView::CWriteSmsView()
{
}
// EPOC default constructor can leave.
void CWriteSmsView::ConstructL()
{
BaseConstructL(R_WRITESMS_VIEW);
}
// Destructor
CWriteSmsView::~CWriteSmsView()
{
delete iEngine;
}
// ---------------------------------------------------------
// TUid CWriteSmsView::Id()
// Returns Id of the view.
// ---------------------------------------------------------
TUid CWriteSmsView::Id() const
{
return KWriteSmsId;
}
// ---------------------------------------------------------
// CWriteSmsView::HandleCommandL(TInt aCommand)
// Handles commands
// ---------------------------------------------------------
void CWriteSmsView::HandleCommandL(TInt aCommand)
{
switch(aCommand)
{
case EHelperGeniusCmdAddReceiver://确定
{
TBuf<32> buf(_L("无名片"));
CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
informationNote->ExecuteLD(buf);
//AppUi()->ActivateLocalViewL(KWriteSmsId);
break;
}
case EHelperGeniusCmdSend://发送
{
{
if (!iEngine->IsReady())
return;
}
TBuf<12> sBufAddress;
TBuf<80> sBufContent;
sBufAddress.Zero();
sBufContent.Zero();
iContainer->GetAddress(sBufAddress);
if ( 0 == sBufAddress.Length() )
{
TBuf<32> buf(_L("无联系人"));
CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
informationNote->ExecuteLD(buf);
break;
}
iContainer->GetContent(sBufContent);
iEngine->CreateDraftSMSL(sBufAddress, sBufContent);
if (!iEngine->ValidateSMS())
{
NotifyMessageInvalidL();
}
else
{
iEngine->SendSMSL();
}
break;
}
case EHelperGeniusCmdRemove://清空
{
// AppUi()->ActivateLocalViewL(KNoteId);
break;
}
case EHelperGeniusCmdSave://存储
{
// AppUi()->ActivateLocalViewL(KNoteId);
break;
}
case EHelperGeniusCmdBack://返回到 smsview
{
AppUi()->ActivateLocalViewL(KSmsId);
break;
}
default:
AppUi()->HandleCommandL(aCommand);
break;
}
}
// ---------------------------------------------------------
// CWriteSmsView::HandleClientRectChange()
// Handles client rect change.
// ---------------------------------------------------------
void CWriteSmsView::HandleClientRectChange()
{
if (iContainer)
{
iContainer->SetRect(ClientRect());
}
}
// ---------------------------------------------------------
// CWriteSmsView::DoActivateL(...)
// Creates the Container class object.
// ---------------------------------------------------------
void CWriteSmsView::DoActivateL(const TVwsViewId& /*aPrevViewId*/,
TUid /*aCustomMessageId*/,
const TDesC8& /*aCustomMessage*/)
{
// Create engine
iEngine = CMtmsExampleEngine::NewL(*this);
iContainer = new (ELeave) CWriteSmsContainer;
iContainer->SetMopParent(this);
TRect rc;
rc.SetRect(ClientRect().iTl, TSize(176, 144));
iContainer->ConstructL(rc);
AppUi()->AddToStackL(*this, iContainer);
TBuf<KMaxPath> pathMbm;
#ifdef __WINS__
pathMbm.Copy(_L("z:\\system\\apps\\HelperGenius\\HelperGenius.mbm"));
#else
CHelperGeniusAppUi* pApp = (CHelperGeniusAppUi*)CEikonEnv::Static()->AppUi();
pApp->GetAppPath(pathMbm);
pathMbm.Append(_L("HelperGenius.mbm"));
#endif
CEikStatusPane* statusPane = StatusPane();
//set icon
CAknContextPane* contextPane=(CAknContextPane*) statusPane->ControlL(TUid::Uid(EEikStatusPaneUidContext));
CFbsBitmap* bitmap = iEikonEnv->CreateBitmapL(pathMbm, EMbmHelpergeniusWritesms);
CFbsBitmap* bitmapMask = iEikonEnv->CreateBitmapL(pathMbm, EMbmHelpergeniusWritesms_mask);
//contextPane->SetPicture(bitmap);
contextPane->SetPicture(bitmap, bitmapMask);
TBuf<32> sTmpTitle;
CEikonEnv::Static()->ReadResource(sTmpTitle, R_QTN_MH_WRITESMS_TITLE);
CAknTitlePane* titlePane = (CAknTitlePane*) statusPane->ControlL(TUid::Uid(EEikStatusPaneUidTitle));
titlePane->SetTextL(sTmpTitle);
}
// ---------------------------------------------------------
// CWriteSmsView::DoDeactivate()
// Deletes the Container class object.
// ---------------------------------------------------------
void CWriteSmsView::DoDeactivate()
{
if (iContainer)
{
AppUi()->RemoveFromStack(iContainer);
delete iContainer;
iContainer = NULL;
}
}
void CWriteSmsView::NotifyMessageInvalidL()
{
CAknErrorNote* note = new (ELeave) CAknErrorNote;
note->ExecuteLD(KInvalidMessage);
}
// TInt CWriteSmsView::GetAddressL()
// {
// CAknTextQueryDialog* dlg = new (ELeave) CAknTextQueryDialog(iAddress, CAknQueryDialog::ENoTone);
// return dlg->ExecuteLD(R_MTMS_EXAMPLE_ADDRESS_QUERY);
// }
void CWriteSmsView::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 + -