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

📄 infraredtransport.h

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

#ifndef INFRAREDTRANSPORT_H
#define INFRAREDTRANSPORT_H

#include <ir_sock.h>

#include "serialutils.h"
#include "transport.h"


/** Server port number, this is the client's remote port number. */
const TInt KIrSocketPortNum = 3;

class CInfraredTransport : public CTransport
/**
	Functionality required by both infrared host (receiver) and client (sender.)
	
	This class manages exchanging data between the devices.  The subclasses
	handle the initial connection.
 */
	{
public:
	static CInfraredTransport* NewL(TAny* aTransportCreateInfo);
	virtual ~CInfraredTransport();
	
protected:
	CInfraredTransport(MTransportObserver& aObserver);
	void ConstructL(const TDesC& aProtocolName);
	void CloseDataSocket();
	
	// implement CActive
	virtual void DoCancel();
	// override CTransport
	virtual void RunL();
	
	// implement CTransport
	virtual void DoSendPayloadL();
	virtual void DoLaunchRead();
	
private:
	static CInfraredTransport* New2L(MTransportObserver& aObserver, const TDesC& aProtocolName, TBool aInitListen);
	
private:
	/** Contains 8-bit version of incoming or outgoing payload. */
	TBuf8<KPayloadLen> iPayload8;
	/** Whether the serial LDD was successfully opened. */
	TBool iLoadedLdd;
	/** Whether the serial PDD was successfully opened. */
	TBool iLoadedPdd;
	
protected:
	/** Connection to socket server.  Used to get protocol information and to connect sockets. */
	RSocketServ iSocketServ;
	/**
		The receiver uses this information to create a listening port;
		the sender uses it to open a host resolver.  Both use it to open
		the data socket.
	 */
	TProtocolDesc iProtoDesc;
	/** Socket which is connected to the remote device. */
	RSocket iSocket;
	};


class CIrServerToClient : public CInfraredTransport
/**
	This transport augments CInfraredTransport by additionally
	setting up a listen socket and accepting a connection from the client.
 */
	{
public:
	static CIrServerToClient* NewL(MTransportObserver& aObserver, const TDesC& aProtocolName);
	virtual ~CIrServerToClient();
	
private:
	CIrServerToClient(MTransportObserver& aObserver);
	void ConstructL(const TDesC& aProtocolName);
	
	// implement CActive, override CInfraredTransport
	virtual void DoCancel();
	virtual void RunL();
	
private:
	/** Socket listens for incoming connection. */
	RSocket iListenSocket;
	/** Whether this object has already accepted an incoming connection. */
	TBool iAccepted;
	/** Error which occured during accept operation. */
	TInt iAcceptError;
	};

class CIrClientToServer : public CInfraredTransport
/**
	Augments CInfraredTransport by additionally connecting to the
	host device.
 */
	{
public:
	static CIrClientToServer* NewL(MTransportObserver& aObserver, const TDesC& aProtocolName);
	virtual ~CIrClientToServer();
	
private:
	CIrClientToServer(MTransportObserver& aObserver);
	void ConstructL(const TDesC& aProtocolName);
	
	// implement CActive, override CInfraredTransport
	virtual void DoCancel();
	virtual void RunL();
	
private:
	/** Whether this device has connected to the remote host. */
	TBool iConnected;
	/** Error during connection. */
	TInt iConnectError;
	};

#endif	// #ifdef INFRAREDTRANSPORT_H

⌨️ 快捷键说明

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