?? infraredtransport.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 + -