plugins/networking/winsockprt/inc/wsp_provider.h
changeset 0 7f656887cf89
equal deleted inserted replaced
-1:000000000000 0:7f656887cf89
       
     1 // wsp_provider.h
       
     2 // 
       
     3 // Copyright (c) 2002 - 2010 Accenture. All rights reserved.
       
     4 // This component and the accompanying materials are made available
       
     5 // under the terms of the "Eclipse Public License v1.0"
       
     6 // which accompanies this distribution, and is available
       
     7 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 // 
       
     9 // Initial Contributors:
       
    10 // Accenture - Initial contribution
       
    11 //
       
    12 
       
    13 #ifndef __WSP_PROVIDER_H__
       
    14 #define __WSP_PROVIDER_H__
       
    15 
       
    16 #include <es_prot.h>
       
    17 #include <in_sock.h>
       
    18 #include "wsp_socket.h"
       
    19 
       
    20 class RWin32Factory;
       
    21 
       
    22 class CWinSockProviderBase : public CServProviderBase, public MWin32SocketObserver
       
    23 	{
       
    24 protected:
       
    25 	virtual ~CWinSockProviderBase();
       
    26 protected: // From CServProviderBase.
       
    27 	virtual void LocalName(TSockAddr& anAddr) const;
       
    28 	virtual TInt SetLocalName(TSockAddr& anAddr);
       
    29 	virtual TInt SetRemName(TSockAddr& anAddr);
       
    30 	virtual TInt GetOption(TUint aLevel, TUint aName, TDes8& anOption) const;
       
    31 	virtual TInt SetOption(TUint aLevel, TUint aName, const TDesC8& anOption);
       
    32 	virtual void AutoBind();
       
    33 	virtual void Ioctl(TUint aLevel, TUint aName, TDes8* anOption);
       
    34 	virtual void CancelIoctl(TUint aLevel, TUint aName);
       
    35 	virtual TInt PassiveOpen(TUint aQue, const TDesC8& aConnectionData);
       
    36 	virtual void Shutdown(TCloseType option, const TDesC8& aDisconnectData);
       
    37 	virtual void ActiveOpen(const TDesC8& aConnectionData);
       
    38 	virtual void Shutdown(TCloseType option);
       
    39 protected:
       
    40 	CWinSockProviderBase(RWin32Factory& aWin32Factory);
       
    41 	void ConstructL();
       
    42 	TInt FillSendBuffer(const TDesC8& aDataToSend);
       
    43 protected:
       
    44 	TInetAddr iRemoteAddr;
       
    45 	RWin32Factory& iWin32Factory;
       
    46 	RWin32Socket iWin32Socket;
       
    47 	CWin32SocketWrapper* iSendSocketWrapper;
       
    48 	CWin32SocketWrapper* iReceiveSocketWrapper;
       
    49 	HBufC8* iSendBuffer;
       
    50 	HBufC8* iReceiveBuffer;
       
    51 	TPtrC8 iEsockReadBuffer;	// A constant pointer descriptor over iReceiveBuffer, used to pass received data up to ESock.
       
    52 	TPtr8 iWinSockWriteBuffer;	// A pointer descriptor over iRecevieBuffer, used to receive data from WinSock.
       
    53 	};
       
    54 
       
    55 
       
    56 class CWinSockTcpProvider : public CWinSockProviderBase
       
    57 	{
       
    58 public:
       
    59 	static CWinSockTcpProvider* NewL(RWin32Factory& aWin32Factory);
       
    60 	static CWinSockTcpProvider* NewBlankLC(RWin32Factory& aWin32Factory);
       
    61 private: // From CServProviderBase.
       
    62 	virtual void RemName(TSockAddr& anAddr) const;
       
    63 	virtual TUint Write(const TDesC8& aDesc, TUint options, TSockAddr* anAddr=NULL);
       
    64 	virtual void GetData(TDes8 &aDesc, TUint options, TSockAddr *anAddr=NULL);
       
    65 	virtual void Start();
       
    66 	virtual void ActiveOpen(void);
       
    67 	virtual TInt PassiveOpen(TUint aQue);
       
    68 	virtual TInt GetOption(TUint aLevel, TUint aName, TDes8& anOption) const;
       
    69 	virtual TInt SetOption(TUint aLevel, TUint aName, const TDesC8& anOption);
       
    70 private: // From MWin32SocketObserver.
       
    71 	virtual void HandleWin32SocketCompletion(TRequestType aRequestType, TInt aError);
       
    72 private:
       
    73 	virtual ~CWinSockTcpProvider();
       
    74 	CWinSockTcpProvider(RWin32Factory& aWin32Factory);
       
    75 	void ConstructL(RWin32Socket::TType aType);
       
    76 	void SetListeningSap(CWinSockTcpProvider& aListeningSap);
       
    77 	void HandleListeningSapStarted();
       
    78 	void DoPassiveOpenL(TUint aQue);
       
    79 	void StartReceive();
       
    80 private:
       
    81 	CWin32SocketWrapper* iConnectSocketWrapper;
       
    82 	CWin32SocketWrapper* iAcceptSocketWrapper;
       
    83 	CWinSockTcpProvider* iAcceptSap;
       
    84 	CWinSockTcpProvider* iListeningSap;
       
    85 	};
       
    86 
       
    87 
       
    88 class CWinSockUdpProvider : public CWinSockProviderBase
       
    89 	{
       
    90 public:
       
    91 	static CWinSockUdpProvider* NewL(RWin32Factory& aWin32Factory);
       
    92 private: // From CServProviderBase.
       
    93 	virtual void RemName(TSockAddr& anAddr) const;
       
    94 	virtual TInt SetLocalName(TSockAddr& anAddr);
       
    95 	virtual TUint Write(const TDesC8& aDesc, TUint options, TSockAddr* anAddr=NULL);
       
    96 	virtual void GetData(TDes8 &aDesc, TUint options, TSockAddr *anAddr=NULL);
       
    97 	virtual void Start();
       
    98 	virtual void ActiveOpen(void);
       
    99 	virtual TInt PassiveOpen(TUint aQue);
       
   100 private: // From MWin32SocketObserver.
       
   101 	virtual void HandleWin32SocketCompletion(TRequestType aRequestType, TInt aError);
       
   102 private:
       
   103 	virtual ~CWinSockUdpProvider();
       
   104 	CWinSockUdpProvider(RWin32Factory& aWin32Factory);
       
   105 	void ConstructL();
       
   106 private:
       
   107 	TInetAddr iReceiveFromAddress;
       
   108 	};
       
   109 
       
   110 
       
   111 #endif // __WSP_PROVIDER_H__