applayerpluginsandutils/httptransportplugins/httptransporthandler/csocketreader.h
changeset 0 b16258d2340f
equal deleted inserted replaced
-1:000000000000 0:b16258d2340f
       
     1 // Copyright (c) 2001-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 __CSOCKETREADER_H__
       
    17 #define __CSOCKETREADER_H__
       
    18 
       
    19 #include <e32base.h>
       
    20 #include <http/framework/logging.h>
       
    21 
       
    22 #include "minputstream.h"
       
    23 #include "mhttptimerobserver.h"
       
    24 #include "chttptimer.h"
       
    25 
       
    26 class CSocket;
       
    27 class MInputStreamObserver;
       
    28 class MSocketController;
       
    29 
       
    30 class CSocketReader : public CActive,
       
    31 					  public MInputStream,
       
    32 					  public MHttpTimerObserver
       
    33 /**	                                         
       
    34 	The CSocketReader class encapsulates the reading functionality and behaviour
       
    35 	for a connected socket. It implements the MInputStream API.
       
    36 	@see		MInputStream
       
    37 	@internalComponent
       
    38 */
       
    39 	{
       
    40 public:	// methods
       
    41 
       
    42 	static CSocketReader* NewL(CSocket& aSocket, MSocketController& aController, TInt aRecvBufferSize, TBool aPriority);
       
    43 
       
    44 	virtual ~CSocketReader();
       
    45 
       
    46 	void SocketClosed(TInt aError);
       
    47 
       
    48 	void Suspend();
       
    49 
       
    50 	void Resume();
       
    51 
       
    52 private:	// methods from MInputStream
       
    53 
       
    54 	virtual void Bind(MInputStreamObserver& aObserver);
       
    55 
       
    56 	virtual void ReceivedDataRes();
       
    57 
       
    58 	virtual void ShutdownReq();
       
    59 
       
    60 	virtual void SecureServerReq();
       
    61 
       
    62 	virtual void Close();
       
    63 
       
    64 	virtual const CX509Certificate* ClientCert();
       
    65 
       
    66 	virtual void Shutdown();
       
    67 	
       
    68 	virtual void Reset();
       
    69 	
       
    70 	virtual TInt ImmediateRead ( TPtrC8& aData );
       
    71 	
       
    72 	virtual void Restart ();
       
    73 	
       
    74 	virtual void StartReceieveTimer (TInt aTimeoutValue);
       
    75 	
       
    76 private:	// methods from CActive
       
    77 
       
    78 	virtual void RunL();
       
    79 	
       
    80 	virtual void DoCancel();
       
    81 	
       
    82 	virtual TInt RunError(TInt aError);
       
    83 
       
    84 private:	// methods from MHttpTimerObserver
       
    85 	
       
    86 	virtual void TimeOut();
       
    87 
       
    88 private:	// methods
       
    89 
       
    90 	CSocketReader(CSocket& aSocket, MSocketController& aController, TBool aPriority);
       
    91 
       
    92 	void CompleteSelf();
       
    93 	
       
    94 	void ConstructL( TInt aRecvBufferSize );
       
    95 
       
    96 private:	// enums
       
    97 
       
    98 /**	
       
    99 	The state machine for the input stream.
       
   100 */
       
   101 	enum TInputState
       
   102 		{
       
   103 		/** The input stream is waiting for an observer to bind itself to it 
       
   104 			before doing a read. 
       
   105 		*/
       
   106 		EIdle			= 0,
       
   107 		/** The input stream has an observer and it requested a read from the socket.
       
   108 		*/
       
   109 		ERead,
       
   110 		/**	The input stream has received a buffer of data from the socket.
       
   111 		*/
       
   112 		EReceivedData,
       
   113 		/**	The input stream is waiting for the observer to notify it that it 
       
   114 			has finished with the current data.
       
   115 		*/
       
   116 		EPendingAck,
       
   117 		/**	The observer has asked the input stream to close the socket.
       
   118 		*/
       
   119 		EClosing,
       
   120 		/**	The socket has been closed - data can no longer be received from it.
       
   121 		*/
       
   122 		EClosed
       
   123 		};
       
   124 
       
   125 private:	// attributes
       
   126 
       
   127 /** The connected socket.
       
   128 */
       
   129 	CSocket&					iSocket;
       
   130 
       
   131 /** The socket controller that owns the socket.
       
   132 */
       
   133 	MSocketController&			iController;
       
   134 
       
   135 /** The buffer into which the received data is placed.
       
   136 */
       
   137 	RBuf8						iBuffer;
       
   138 
       
   139 /**	The state of the input stream.
       
   140 */
       
   141 	TInputState					iState;
       
   142 
       
   143 /**	Flag to indicate that the stream is suspended.
       
   144 */
       
   145 	TBool						iSuspended;
       
   146 
       
   147 /** The observer for the input stream.
       
   148 */
       
   149 	MInputStreamObserver*		iObserver;
       
   150 	
       
   151 //CHttpTimer Object
       
   152 	CHttpTimer*					iReceiveTimer;
       
   153 
       
   154 public:	// attributes
       
   155 
       
   156 /** Logger handle
       
   157 */
       
   158 	__FLOG_DECLARATION_MEMBER2
       
   159 
       
   160 	};
       
   161 
       
   162 #endif	// __CSOCKETREADER_H__