plugins/networking/tcpcsy/src/tcpcsy.h
changeset 0 7f656887cf89
equal deleted inserted replaced
-1:000000000000 0:7f656887cf89
       
     1 // tcpcsy.h
       
     2 // 
       
     3 // Copyright (c) 2008 - 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 __TCPCSY_H__
       
    14 #define __TCPCSY_H__
       
    15 
       
    16 
       
    17 #include <cs_port.h>
       
    18 #include "config.h"
       
    19 #include "reader.h"
       
    20 #include "writer.h"
       
    21 #include "connector.h"
       
    22 #include "listener.h"
       
    23 #include "tcpcsylog.h"
       
    24 
       
    25 
       
    26 //
       
    27 // Constants.
       
    28 //
       
    29 
       
    30 _LIT(KCsyName, "tcpcsy");
       
    31 
       
    32 
       
    33 //
       
    34 // Forward declarations.
       
    35 //
       
    36 class CTcpPort;
       
    37 
       
    38 
       
    39 //
       
    40 // Class Definitions.
       
    41 //
       
    42 
       
    43 
       
    44 class CTcpPortFactory : public CSerial
       
    45 	{
       
    46 public:
       
    47     static CTcpPortFactory* NewL();
       
    48     ~CTcpPortFactory();
       
    49 private:	// From CSerial.
       
    50 	virtual CPort * NewPortL(const TUint aUnit);
       
    51 	virtual void Info(TSerialInfo &aSerialInfo);
       
    52 	virtual TSecurityPolicy PortPlatSecCapability(TUint aPort) const;
       
    53 private:
       
    54 	CTcpPortFactory();
       
    55 	void ConstructL();
       
    56 private:
       
    57 	RSocketServ iSocketServ;
       
    58 	CConfig* iConfig;
       
    59 	TDblQue<CTcpPort> iPorts;
       
    60 public:
       
    61 #ifdef __FLOG_ACTIVE
       
    62 
       
    63 #ifdef LOG_CSY_EVENTS
       
    64 	RFileLogger iEventLogger;
       
    65 #endif // LOG_CSY_EVENTS
       
    66 
       
    67 #ifdef LOG_CSY_TX
       
    68 	RFileLogger iTxLogger;
       
    69 #endif // LOG_CSY_TX
       
    70 
       
    71 #ifdef LOG_CSY_RX
       
    72 	RFileLogger iRxLogger;
       
    73 #endif // LOG_CSY_RX
       
    74 
       
    75 #endif // __FLOG_ACTIVE
       
    76 	};
       
    77 
       
    78 
       
    79 class CTcpPort : public CPort, public MConnectorObserver, public MListenerObserver, public MReaderObserver, public MWriterObserver
       
    80 	{
       
    81 public:
       
    82 	static TInt LinkOffset();
       
    83 	static CTcpPort* NewLC(CTcpPortFactory& aFactory, CConfig::TMode aMode, TUint aProtocolFamily, TUint aProtocol, const TInetAddr& aAddress, RSocketServ& aSocketServ);
       
    84 public:	// From CPort.
       
    85 	virtual void StartRead(const TAny* aClientBuffer, TInt aLength);
       
    86 	virtual void ReadCancel();
       
    87 	virtual TInt QueryReceiveBuffer(TInt& aLength) const;
       
    88 	virtual void ResetBuffers(TUint aFlags);
       
    89 	virtual void StartWrite(const TAny* aClientBuffer, TInt aLength);
       
    90 	virtual void WriteCancel();
       
    91 	virtual void Break(TInt aTime);
       
    92 	virtual void BreakCancel();
       
    93 	virtual TInt GetConfig(TDes8& aDes) const;
       
    94 	virtual TInt SetConfig(const TDesC8& aDes);
       
    95 	virtual TInt SetServerConfig(const TDesC8& aDes);
       
    96 	virtual TInt GetServerConfig(TDes8& aDes);
       
    97 	virtual TInt GetCaps(TDes8& aDes);
       
    98 	virtual TInt GetSignals(TUint& aSignals);
       
    99 	virtual TInt SetSignalsToMark(TUint aSignals);
       
   100 	virtual TInt SetSignalsToSpace(TUint aSignals);
       
   101 	virtual TInt GetReceiveBufferLength(TInt& aLength) const;
       
   102 	virtual TInt SetReceiveBufferLength(TInt aSignals);
       
   103 	virtual void Destruct();
       
   104 	virtual void FreeMemory();
       
   105 	virtual void NotifySignalChange(TUint aSignalMask);
       
   106 	virtual void NotifySignalChangeCancel();
       
   107 	virtual void NotifyConfigChange();
       
   108 	virtual void NotifyConfigChangeCancel();
       
   109 	virtual void NotifyFlowControlChange();
       
   110 	virtual void NotifyFlowControlChangeCancel();
       
   111 	virtual void NotifyBreak();
       
   112 	virtual void NotifyBreakCancel();
       
   113 	virtual void NotifyDataAvailable();
       
   114 	virtual void NotifyDataAvailableCancel();
       
   115 	virtual void NotifyOutputEmpty();
       
   116 	virtual void NotifyOutputEmptyCancel();
       
   117 	virtual TInt GetFlowControlStatus(TFlowControl& aFlowControl);
       
   118 	virtual TInt GetRole(TCommRole& aRole);
       
   119 	virtual TInt SetRole(TCommRole aRole);
       
   120 public: // From MConnectorObserver.
       
   121 	virtual void ConnectionComplete(TInt aError);
       
   122 public: // From MListenerObserver.
       
   123 	virtual void ListenComplete(TInt aError);
       
   124 public: // From MReaderObserver.
       
   125 	virtual void ReadComplete(const TDesC8& aData);
       
   126 	virtual void ReadError(TInt aError);
       
   127 public: // From MWriterObserver.
       
   128 	virtual void WriteComplete(TInt aError);
       
   129 private:
       
   130 	virtual ~CTcpPort();
       
   131 	CTcpPort(CTcpPortFactory& aFactory);
       
   132 	void ConstructL(CConfig::TMode aMode, TUint aProtocolFamily, TUint aProtocol, const TInetAddr& aAddress, RSocketServ& aSocketServ);
       
   133 private:
       
   134 	TDblQueLink iLink;
       
   135 	CTcpPortFactory& iFactory;
       
   136 	RSocket iSocket;
       
   137 	TBool iSocketConnected;
       
   138 	CConnector* iConnector;
       
   139 	CListener* iListener;
       
   140 	CReader* iReader;
       
   141 	CWriter* iWriter;
       
   142 	RBuf8 iWriteBuf;
       
   143 	TInt iError;
       
   144 	TInetAddr iInetAddr;
       
   145 	TCommRole iRole;
       
   146 	};
       
   147 
       
   148 #endif // __TCPCSY_H__