⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 transport.h

📁 Symbian OS C++ for Mobile Phones Volume 3 源码
💻 H
字号:
// Copyright (c) 2004 - 2007, Symbian Software Ltd. All rights reserved.

#ifndef TRANSPORT_H
#define TRANSPORT_H

#include <transportinterface.h>


class CTransport : public CTransportInterface
/**
	Provides functionality which is common to all
	transport interface implementations.
 */
	{
protected:
	IMPORT_C CTransport(MTransportObserver& aObserver);
	IMPORT_C void ConstructL(TBool aInitListen);

	// partially implement CActive
	IMPORT_C virtual void RunL();
	IMPORT_C virtual TInt RunError(TInt aError);

	IMPORT_C void CompleteSelf(TInt aError);
	IMPORT_C void CompleteSelfIfError(TInt aError);

private:
	// implement CTransportInterface
	IMPORT_C virtual void SendPayload(const TDesC& aPayload);
	void LaunchRead();

	/** Write iPayload to the remote device, completing this AO when finished. */
	virtual void DoSendPayloadL() = 0;
	/** Read KPayloadLen characters into iPayload, completing this AO when finished. */
	virtual void DoLaunchRead() = 0;

protected:
	/** Whether this transport is listening for an incoming payload. */
	TBool iListening;
	/** Buffer contains payload which is being sent to or received from the remote device. */
	TBuf<KPayloadLen> iPayload;
	/**
		Observer to notify when transport events occur, and
		which also raises dialogs during blocking operations.
	 */
	MTransportObserver& iObserver;
	};


// -------- debugging --------

#ifdef _DEBUG

enum TTransPanicReason
/** Invalid states for the generic transport layer. */
	{
	ESpListening,			//<<< Attempted to read payload when already reading.
	ESpInvalidLength,		//<<< Attempted to send payload with invalid length
	};

void TransPanic(TTransPanicReason aReason);

#endif	// #ifdef _DEBUG


// -------- app-specific error codes --------

/**
	The supplied message was not a payload response.  This error code
	distinguishes not finding a message from an actual error such as
	running out of memory.
 */
const TInt KErrOandXMessageNotFound = -20001;

#endif	// #ifndef TRANSPORT_H

⌨️ 快捷键说明

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