applayerpluginsandutils/httptransportplugins/httptransporthandler/csocket.h
changeset 0 b16258d2340f
child 7 337070b4fa18
equal deleted inserted replaced
-1:000000000000 0:b16258d2340f
       
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef __CSOCKET_H__
       
    17 #define __CSOCKET_H__
       
    18 
       
    19 #include <e32base.h>
       
    20 #include <in_sock.h>
       
    21 
       
    22 class MCommsInfoProvider;
       
    23 class CHttpSecureSocket;
       
    24 class CX509Certificate;
       
    25 
       
    26 class CSocket: public CBase
       
    27 /**	
       
    28 	The CSocket class encapsulates a socket. It provides a limited version of
       
    29 	the RSocket API. It can expanded to encapsulate the CSecureSocket API too.
       
    30 	@internalComponent
       
    31 */
       
    32 	{
       
    33 public:	// enums
       
    34 
       
    35 /**	
       
    36 	The TSocketType enumerates the type of socket, e.g if the socket should be
       
    37 	initiased for a specified protocol. Can be expanded to specify a secure 
       
    38 	socket.
       
    39 	
       
    40 */
       
    41 	enum TSocketType
       
    42 		{
       
    43 		/**	The socket should be initialised for the specified protocol.
       
    44 		*/
       
    45 		EProtocolSocket			= 0,
       
    46 		/**	The socket should be not be initialised for any protocol.
       
    47 		*/
       
    48 		EBlankSocket,
       
    49 		};
       
    50 
       
    51 public:	// methods
       
    52 
       
    53 	static CSocket* NewL(MCommsInfoProvider& aCommsInfoProvider, TSocketType aSocketType);
       
    54 
       
    55 	virtual ~CSocket();
       
    56 
       
    57 	TInt Listen(TUint aQSize, TUint16 aPort);
       
    58 
       
    59 	void Accept(CSocket& aBlankSocket, TRequestStatus& aStatus);
       
    60 
       
    61 	void CancelAccept();
       
    62 
       
    63 	void Connect(TInetAddr& aAddr, TRequestStatus& aStatus);
       
    64 
       
    65 	void CancelConnect();
       
    66 
       
    67 	void RecvOneOrMore(TDes8& aBuffer, TRequestStatus& aStatus);
       
    68 
       
    69 	void CancelRecv();
       
    70 
       
    71 	void Send(const TDesC8& aBuffer, TRequestStatus& aStatus);
       
    72 
       
    73 	void CancelSend();
       
    74 
       
    75 	void Shutdown(TRequestStatus& aStatus);
       
    76 	
       
    77 	void ShutdownImmediate();
       
    78 
       
    79 	void RemoteName(TInetAddr& aAddr);
       
    80 
       
    81 	void LocalName(TInetAddr& aAddr);
       
    82 
       
    83 	const CX509Certificate* ServerCert();
       
    84 	
       
    85 	TInt CipherSuite(TDes8& aCipherSuite);
       
    86 
       
    87 	void UpgradeToSecureL(TRequestStatus& aStatus, const TDesC8& aHostName);
       
    88 
       
    89 	void CancelUpgradeToSecure();
       
    90 
       
    91 	TInt PendingBytesToRead ();
       
    92 	
       
    93 	void SetTCPCorking(TBool aValue);
       
    94 
       
    95 private:	// methods
       
    96 
       
    97 	CSocket(MCommsInfoProvider& aCommsInfoProvider);
       
    98 
       
    99 	void ConstructL(TSocketType aSocketType);
       
   100 
       
   101 private:
       
   102 
       
   103 /**	The comms info provider
       
   104 */
       
   105 	MCommsInfoProvider&		iCommsInfoProvider;
       
   106 
       
   107 /**	The socket.
       
   108 */
       
   109 	RSocket					iSocket;
       
   110 
       
   111 /**	The number of bytes read.
       
   112 */
       
   113 	TSockXfrLength			iBytesReceived;
       
   114 
       
   115 /** Controller for secure sockets, only created if a secure socket is required
       
   116 */
       
   117 	CHttpSecureSocket* iSecureSocketController;
       
   118 	};
       
   119 
       
   120 #endif	// __CSOCKET_H__