/*
* ============================================================================
* Name : CMMSExampleContainer from MMSExampleContainer.h
* Part of : MMSExample
* Created : 04.11.2006 by Forum Nokia
* Implementation notes:
* Initial content was generated by Nokia Series 60 AppWizard.
* Version : 2.0
* Copyright: Nokia Corporation
* ============================================================================
*/
// INCLUDE FILES
#include "MMSExampleContainer.h"
#include "MMSExample.hrh"
#include "MMSExamplePanics.pan"
#include <eikrted.h> //RichText Editor
#include <txtrich.h> // CRichText
#include <mtclreg.h> // for CClientMtmRegistry
#include <msvids.h> // for Message type IDs
#include <mmsclient.h> // for CMmsClientMtm
#include <AknQueryDialog.h> // for CAknTextQueryDialog
#include <barsread.h> // for TResourceReader
#include <f32file.h>
#include <coeutils.h> // Check the file exist
#include <CMsvMimeHeaders.h> //Attachemt mimeheader
#include <MMsvAttachmentManager.h> //Attachment manager
#include <PathInfo.h>
#define KDirPictures PathInfo::ImagesPath()
#define KPhoneRootPath PathInfo::PhoneMemoryRootPath()
//Constants
const TInt KMaxAddressLength = 20; // maximum length for a recipient address
_LIT( KFileName, "mmsexample.jpg" ); //Attachment file name
/*
-------------------------------------------------------------------------------
CMMSExampleContainer::ConstructL()
Description: 2nd phase Constructor.
-------------------------------------------------------------------------------
*/
void CMMSExampleContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
iRecipient = HBufC::NewL(KMaxAddressLength);// for recipient address (gsm number)
// Create CMsvSession
iSession = CMsvSession::OpenAsyncL(*this);// new session is opened asynchronously
// Create RichTextEditor
iRtEd = new (ELeave) CEikRichTextEditor;
// Setting RichTextEditor flags
iRtEd->SetAknEditorCase(EAknEditorLowerCase);
// Fixed case
iRtEd->SetAknEditorFlags
(
EAknEditorFlagFixedCase| //Set up the Allowed Cases
EAknEditorFlagEnableScrollBars // Set up the scroller
);
iRtEd->ConstructL(this,0,0,CEikEdwin::ENoAutoSelection|CEikEdwin::EReadOnly);
iRtEd->SetFocus(ETrue);
iRtEd->UpdateScrollBarsL();
SetRect(aRect);
ActivateL();
SizeChanged();
}
/*
-----------------------------------------------------------------------------
CMMSExampleContainer::CompleteConstructL()
Creates client MTM registry when session is ready for use.
This completes model construction and is called after 'server
ready' event is received after async opening of CMsvSession.
-----------------------------------------------------------------------------
*/
void CMMSExampleContainer::CompleteConstructL()
{
// We get a MtmClientRegistry from our session
// this registry is used to instantiate new mtms.
iMtmReg = CClientMtmRegistry::NewL(*iSession);
iMmsMtm = (CMmsClientMtm*) iMtmReg->NewMtmL( KUidMsgTypeMultimedia );
_LIT(KSessionOpen, "Server session opened.");
EchoL(KSessionOpen);
}
// ---------------------------------------------------------
// CRTEContainer::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CMMSExampleContainer::SizeChanged()
{
TRect rect = Rect();
TRect ScrollBarRect = iRtEd->ScrollBarFrame()->VerticalScrollBar()->Rect();
//In 3rd edition CEikRichTextEditor draw the view for the whole rect and
//the scrollbar doesn't show. That is a reason why CEikRichTextEditor Width() is
//rect.Width()-ScrollBarRect.Width()
iRtEd->SetExtent(TPoint(0,0),
TSize(rect.Width()-ScrollBarRect.Width(), rect.Height()));
}
/*
-----------------------------------------------------------------------------
CMMSExampleContainer::~CMMSExampleAppUi()
Destructor.
-----------------------------------------------------------------------------
*/
CMMSExampleContainer::~CMMSExampleContainer()
{
delete iRtEd;
delete iRecipient;
delete iMmsMtm;
delete iMtmReg;
delete iMsvEntry;
delete iSession; // session must be deleted last (and constructed first)
}
/*
-----------------------------------------------------------------------------
CMMSExampleContainer::HandleSessionEventL()
Receives session events from observer and calls event handling functions.
Note that if additional session event handlers are defined
in the session, they are called before this function (as this is the
main session observer).
The type of event is indicated by the value of aEvent. The
interpretation of the TAny arguments depends on this type.
-----------------------------------------------------------------------------
*/
void CMMSExampleContainer::HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* /*aArg3*/)
{
switch (aEvent)
{
// This event tells us that the session has been opened
case EMsvServerReady:
CompleteConstructL(); // Construct the mtm registry & MMS mtm
break;
case EMsvEntriesCreated:
//Listening when new message is arrived in inbox
if (aArg2 && *(static_cast<TMsvId*>(aArg2)) == KMsvGlobalInBoxIndexEntryId)
{
CMsvEntrySelection* entries = static_cast<CMsvEntrySelection*>(aArg1);
if( entries->Count() >= 1 )
{
_LIT(KMessageReceived, "Message received.");
EchoL(KMessageReceived);
_LIT(KSOpenInbox, "Open inbox.");
EchoL(KSOpenInbox);
}
else
{
Panic(EMmsEngineInternal);
}
}
default:
break;
}
}
/*
-----------------------------------------------------------------------------
CMMSExampleContainer::Draw()
Simple Draw method.
-----------------------------------------------------------------------------
*/
void CMMSExampleContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
gc.SetPenStyle(CGraphicsContext::ENullPen);
gc.SetBrushColor(KRgbWhite);
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
gc.DrawRect(aRect);
}
/*
-----------------------------------------------------------------------------
CMMSExampleContainer::InitializeCommunicationsL()
Initialize a new message and ask the user for a recipient address.
Return values: ETrue or EFalse
-----------------------------------------------------------------------------
*/
TBool CMMSExampleContainer::InitializeCommunicationsL()
{
// First the recipients address
// we get it from a data query dialog.
TBuf<20> addr = iRecipient->Des();
CAknTextQueryDialog* telNumDialog = CAknTextQueryDialog::NewL(addr, CAknQueryDialog::ENoTone);
if (!telNumDialog->ExecuteLD(R_MMSEXAMPLE_TEL_NUMBER_DIALOG))
return EFalse;
iRecipient->Des() = addr; // Note that the user can give both numeric and textual data in the query dialog,
// so the address can be a GSM number or an e-mail address.
// set up a new message
return CreateNewMessageL();
}
/*
-----------------------------------------------------------------------------
CMMSExampleContainer::CreateNewMessageL()
Creates a new message server entry and set up default values.
In case the attachment file does not found method return EFalse
otherwise ETrue.
There are differenses how to add attachment file between 2nd and 3rd edition.
--
guhog
- 粉丝: 20
- 资源: 6
最新资源
- (源码)基于SSM框架的选课管理系统.zip
- C#ASP.NET客户关系OA进销存财务审批工作流HRCRM源码数据库 SQL2008源码类型 WebForm
- (源码)基于Google Firebase和Android系统的智能家居自动化项目.zip
- (源码)基于SSM框架的学生管理系统.zip
- (源码)基于Arduino的循线小车系统.zip
- (源码)基于Unity的六边形网格地图生成系统.zip
- (源码)基于Spring Cloud Alibaba的微服务管理系统.zip
- C#MES加工装配模拟系统源码 工厂加工装配系统源码数据库 SQL2008源码类型 WinForm
- (源码)基于JSP和Servlet的ATM管理系统.zip
- (源码)基于ESP8266的ADXL355传感器数据读取系统.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈