smstransport.cpp

来自「Symbian OS C++ for Mobile Phones v3 Exam」· C++ 代码 · 共 75 行

CPP
75
字号
// Copyright (c) 2004 - 2007, Symbian Software Ltd. All rights reserved.

#include "smstransport.h"


CSmsTransport* CSmsTransport::NewL(TAny* aTransportCreateInfo)
/**
	This factory function is defined so the class can be instantiated
	via ECOM, which means it can only take a single TAny* argument.
	
	@param	aTransportCreateInfo	Pointer to an instance of
							TTransportCreateInfo, which contains the
							data required to allocate the transport.
	@return					Transport that sends messages to a remote
							device over SMS.  This is owned by the caller.
 */
	{
	const TTransportInterfaceCreateInfo& tci =
		*reinterpret_cast<TTransportInterfaceCreateInfo*>(aTransportCreateInfo);
	return New2L(tci.iObserver, *tci.iAddress, tci.iInitListen);
	}

CSmsTransport* CSmsTransport::New2L(MTransportObserver& aObserver, const TDesC& aAddress, TBool aInitListen)
/**
	Factory function allocates new initialized instance of CSmsTransport.
	The returned object can be used to send short messages to and receive
	them from a single remote device.
	
	@param	aObserver		Observer to notify about transport events.
							This is managed by the CTransport superclass.
	@param	aAddress		Remote device's address.  This should be a
							text representation of a telephone number.
	@param	aInitListen		If true, this object should start by listening
							for an incoming payload.  Otherwise, it should
							wait for its owner to send a payload to the remote
							device.
	@return					Transport that sends messages to a remote
							device via SMS.  This is owned by the caller.
	@see NewL
 */
	{
	CSmsTransport* self = new(ELeave) CSmsTransport(aObserver);
	CleanupStack::PushL(self);
	self->ConstructL(aAddress, aInitListen);
	CleanupStack::Pop(self);
	return self;
	}

CSmsTransport::CSmsTransport(MTransportObserver& aObserver)
/**
	This c'tor is defined to pass the supplied observer to the superclass.

	@param	aObserver		Observer to notify about transport events.
							This is managed by the CTransport superclass.
 */
:	CBodyTextTransport(aObserver, KUidMsgTypeSMS)
	{
	// empty.
	}

// -------- implement CMessageTransport --------

TBool CSmsTransport::ShouldUseReceivedMtmUid(TUid aMtmUid) const
/**
	Implement CMessageTransport by testing whether the supplied
	MTM UID identifies a short message MTM.

	@param	aMtmUid			Incoming message's UID.
	@return					Whether aMtmUid describes an SMS MTM.
 */
	{
	return aMtmUid == KUidMsgTypeSMS;
	}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?