applayerpluginsandutils/httpprotocolplugins/WspProtocolHandler/CWspCOTxData.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 __CWSPCOTXDATA_H__
       
    17 #define __CWSPCOTXDATA_H__
       
    18 
       
    19 // System includes
       
    20 #include <e32base.h>
       
    21 #include <http/framework/ctxdata.h>
       
    22 
       
    23 // Forward declarations
       
    24 class MWspCOTxDataCallback;
       
    25 class MWspCapabilityViewer;
       
    26 class MHTTPDataSupplier;
       
    27 
       
    28 // @todo docing
       
    29 
       
    30 //##ModelId=3BBD80700021
       
    31 class CWspCOTxData : public CTxData
       
    32 	{
       
    33 public:	// Methods
       
    34 
       
    35 /**	@fn				NewL(CProtTransaction& aTransaction, MWspCOTxDataCallback& aObserver, MWspCapabilityViewer& aNegotiatedCapInfo)
       
    36 	Intended Usage	:	Static factory constructor.
       
    37 	@since			7.0
       
    38 	@leave			Leaves with KErrNoMemory if there was not enough memory to
       
    39 					create the object.
       
    40 	@param			aTransaction		The protocol transaction object 
       
    41 										associated with the Tx data object.
       
    42 	@param			aObserver			A reference to the Tx data observer
       
    43 	@param			aNegotiatedCapInfo	A reference to the negotiated 
       
    44 										capability viewer object.
       
    45 	@return			A pointer to newly created object.
       
    46 */
       
    47 	//##ModelId=3C4C41A801D3
       
    48 	static CWspCOTxData* NewL(
       
    49 							 CProtTransaction&		aTransaction, 
       
    50 							 MWspCOTxDataCallback&	aObserver, 
       
    51 							 MWspCapabilityViewer&	aNegotiatedCapInfo
       
    52 							 );
       
    53 
       
    54 /**	@fn				~CWspCOTxData()
       
    55 	Intended Usage	:	Standard destructor.
       
    56 	@since			7.0
       
    57 */
       
    58 	//##ModelId=3C4C41A801C9
       
    59 	~CWspCOTxData();
       
    60 
       
    61 /**	@fn				RequestHeadersData()
       
    62 	Intended Usage	:	Provides a buffer with the request headers.
       
    63 	@since			7.0
       
    64 	@return			A const reference to a buffer that contains the	request 
       
    65 					headers.
       
    66 */
       
    67 	//##ModelId=3C4C41A801B5
       
    68 	const TDesC8& RequestHeadersData();
       
    69 
       
    70 /**	@fn				RequestBodyData()
       
    71 	Intended Usage	:	Provides the data supplier object for the request 
       
    72 						body data. This data supplier supplies the more data
       
    73 						flag via the return from GetNextDataPart().
       
    74 	@since			7.0
       
    75 	@return			A reference to a MHTTPDataSupplier object that provides the
       
    76 					request body.
       
    77 */
       
    78 	//##ModelId=3C4C41A801AB
       
    79 	MHTTPDataSupplier& RequestBodyData();
       
    80 
       
    81 /**	@fn				SetRequestDataL()
       
    82 	Intended Usage	:
       
    83 	@since			7.0
       
    84 	@todo			finish docing
       
    85 */
       
    86 	//##ModelId=3C4C41A80197
       
    87 	void SetRequestDataL();
       
    88 
       
    89 /**	@fn				ReceivedCnf()
       
    90 	The cnf for the current invoke primitive has been received. If there is more
       
    91 	data to send, then the observer is asked to send an S-MethodInvokeData 
       
    92 	primitive. If there is no more data to send and the request is not complete
       
    93 	then wait for the client to send more data.
       
    94 	@since			7.0
       
    95 	@pre			The state is either EDone or EGotMoreData.
       
    96 	@post			The has changed to EIdle if the originally EDone. This 
       
    97 					indicates that the request is complete. If the state was
       
    98 					EGotMoreData then the state is EDone if the remaining data
       
    99 					can be sent in the next SDU, EGotMoreData if the remaining
       
   100 					data cannot be all sent in the next SDU, or EWaitForData if
       
   101 					the request is not complete and remaining data does not fill
       
   102 					the next SDU.
       
   103 */
       
   104 	void ReceivedCnf();
       
   105 
       
   106 /**	@fn				NotifyMoreRequestData()
       
   107 	Intended Usage	:	The client has got more request data. 
       
   108 	@since			7.0
       
   109 	@post			The fact that the client has nore request data has been flagged.
       
   110 */
       
   111 	//##ModelId=3C4C41A80179
       
   112 	void NotifyMoreRequestData();
       
   113 	
       
   114 private:	// Methods from MHTTPDataSupplier
       
   115 
       
   116 /**	@fn				GetNextDataPart(TPtrC8& aDataPart)
       
   117 	@see			MHTTPDataSupplier
       
   118 */
       
   119 	//##ModelId=3C4C41A8013C
       
   120 	virtual TBool GetNextDataPart(TPtrC8& aDataPart);
       
   121 
       
   122 /**	@fn				ReleaseData()
       
   123 	@see			MHTTPDataSupplier
       
   124 */
       
   125 	//##ModelId=3C4C41A80128
       
   126 	virtual void ReleaseData();
       
   127 
       
   128 /**	@fn				OverallDataSize()
       
   129 	@see			MHTTPDataSupplier
       
   130 */
       
   131 	//##ModelId=3C4C41A80114
       
   132 	virtual TInt OverallDataSize();
       
   133 
       
   134 /**	@fn				Reset()
       
   135 	@see			MHTTPDataSupplier
       
   136 */
       
   137 	//##ModelId=3C4C41A80100
       
   138 	virtual TInt Reset();
       
   139 
       
   140 private:	// Methods
       
   141 
       
   142 /**	@fn				CWspCOTxData(CProtTransaction& aTransaction, MWspCOTxDataCallback& aObserver, MWspCapabilityViewer& aNegotiatedCapInfo)
       
   143 	Intended Usage	:	First phase constructor.
       
   144 	@since			7.0
       
   145 	@param			aTransaction		The protocol transaction object 
       
   146 										associated with the Tx data object.
       
   147 	@param			aObserver			A reference to the Tx observer.
       
   148 	@param			aNegotiatedCapInfo	A reference to the negotiated 
       
   149 										capability viewer object.
       
   150 */
       
   151 	//##ModelId=3C4C41A8009C
       
   152 	CWspCOTxData(
       
   153 				CProtTransaction&		aTransaction, 
       
   154 				MWspCOTxDataCallback&	aObserver, 
       
   155 				MWspCapabilityViewer&	aNegotiatedCapInfo
       
   156 				);
       
   157 
       
   158 /**	@fn				SetSessionPropertyL(TInt aProperty, THTTPHdrVal aFieldValue)
       
   159 	Intended Usage	:
       
   160 	@since			7.0
       
   161 	@todo			docing
       
   162 	@param			aProperty		An integer specifying the property to be 
       
   163 									set.
       
   164 	@param			aFieldValue		The value the property is to be set to.
       
   165 	@post			The property has been set to the specified value/
       
   166 */
       
   167 	//##ModelId=3C4C41A80056
       
   168 	void SetSessionPropertyL(TInt aProperty, THTTPHdrVal aFieldValue);
       
   169 
       
   170 /**	@fn				SetHeaderDataL(RHTTPRequest aRequest)
       
   171 	Intended Usage	:
       
   172 	@since			7.0
       
   173 	@todo			finish docing
       
   174 	@param			aRequest	The request object.
       
   175 	@pre
       
   176 	@post
       
   177 */
       
   178 	//##ModelId=3C4C41A8002E
       
   179 	void SetHeaderDataL(RHTTPRequest aRequest);
       
   180 
       
   181 /**	@fn				EncodeHeadersL(RHTTPHeaders aHeaders)
       
   182 	Intended Usage	:
       
   183 	@since			7.0
       
   184 	@todo			finish docing
       
   185 	@param			aHeaders	The headers object
       
   186 	@pre
       
   187 	@post
       
   188 */
       
   189 	//##ModelId=3C4C41A80006
       
   190 	void EncodeHeadersL(RHTTPHeaders aHeaders);
       
   191 
       
   192 /**	@fn				SetBodyDataL(MHTTPDataSupplier& aRequestBody)
       
   193 	Intended Usage	:
       
   194 	@since			7.0
       
   195 	@todo			finish docing
       
   196 	@param			aRequestBody	The data supplier for the request body data.
       
   197 	@pre
       
   198 	@post
       
   199 */
       
   200 	//##ModelId=3C4C41A703D0
       
   201 	void SetBodyDataL(MHTTPDataSupplier& aRequestBody);
       
   202 
       
   203 /**	@fn				UpdateBodyData()
       
   204 	Intended Usage	:
       
   205 	@since			7.0
       
   206 	@todo			finish docing
       
   207 	@pre
       
   208 	@post
       
   209 */
       
   210 	//##ModelId=3C4C41A703C6
       
   211 	void UpdateBodyData();
       
   212 
       
   213 /**	@fn				CalculateUIntVarLength(TUint32 aUint)
       
   214 	Intended Usage	:	A utility function to calculate how many bytes are
       
   215 						required to represent a number in UIntVar format, as
       
   216 						defined by the WSP Specification, July 2001.
       
   217 	@since			7.0
       
   218 	@param			aUint	The unsigned positive number for which to calculate
       
   219 							the length of its UIntVar representation.
       
   220 	@return			The number of bytes required to represent the input integer
       
   221 					as a UIntVar.
       
   222 */
       
   223 	//##ModelId=3C4C41A70394
       
   224 	TInt CalculateUIntVarLength(TUint32 aUint);
       
   225 
       
   226 /**	@fn				UpdateState()
       
   227 
       
   228 	@since			7.0
       
   229 */
       
   230 	void UpdateState();
       
   231 
       
   232 /** @fn				CheckTrailer()
       
   233 
       
   234 	@since			7.0
       
   235 */
       
   236 	void CheckTrailer();
       
   237 
       
   238 /**	@fn				DecideObserverAction()
       
   239 
       
   240 	@since			7.0
       
   241 */
       
   242 	void DecideObserverAction();
       
   243 
       
   244 /**	@fn				Cleanup()
       
   245 
       
   246 	@since			7.0
       
   247 */
       
   248 	void Cleanup();
       
   249 
       
   250 private:	// Enums
       
   251 
       
   252 	/** The TRequestState type represents the states of the 
       
   253 		request data object.
       
   254 	*/
       
   255 	enum TRequestState
       
   256 		{
       
   257 		/**
       
   258 		*/
       
   259 		EIdle					= 0,
       
   260 		/**
       
   261 		*/
       
   262 		EDone,
       
   263 		/**
       
   264 		*/
       
   265 		EGotMoreData,
       
   266 		/**
       
   267 		*/
       
   268 		EWaitForMoreData,
       
   269 		/**
       
   270 		*/
       
   271 		EAbortMethod
       
   272 		};
       
   273 
       
   274 private:	// Attributes
       
   275 
       
   276 	/** The state of the request data.
       
   277 	*/
       
   278 	TRequestState			iState;
       
   279 
       
   280 	/**	A reference to Tx data callback object.
       
   281 	*/
       
   282 	//##ModelId=3C4C41A7038A
       
   283 	MWspCOTxDataCallback&	iObserver;
       
   284 
       
   285 	/** A reference to the negotiated capability viewer.
       
   286 	*/
       
   287 	//##ModelId=3C4C41A70376
       
   288 	MWspCapabilityViewer&	iNegotiatedCapInfo;
       
   289 
       
   290 	/** A pointer to the request body data supplier. Not owned.
       
   291 	*/
       
   292 	//##ModelId=3C4C41A70362
       
   293 	MHTTPDataSupplier*		iBodyDataSupplier;
       
   294 
       
   295 	/** A buffer with the encoded request header data.
       
   296 	*/
       
   297 	//##ModelId=3C4C41A70350
       
   298 	HBufC8*					iHeaderData;
       
   299 
       
   300 	/** A buffer with the encoded request trailer header data.
       
   301 	*/
       
   302 	//##ModelId=3C4C41A70344
       
   303 	HBufC8*					iTrailerData;
       
   304 
       
   305 	/** A buffer with the current request data.
       
   306 	*/
       
   307 	HBufC8*					iBodyData;
       
   308 
       
   309 	/** A flag indicating that there are trailer header data.
       
   310 	*/
       
   311 	//##ModelId=3C4C41A70312
       
   312 	TBool					iHasTrailer;
       
   313 
       
   314 	/** A flag that indicates whether all the request data has been received 
       
   315 		from the client.
       
   316 	*/
       
   317 	//##ModelId=3C4C41A702F4
       
   318 	TBool					iRequestComplete;
       
   319 
       
   320 	/** A flag that indicates whether there is a current request body data part.
       
   321 	*/
       
   322 	//##ModelId=3C4C41A702D6
       
   323 	TBool					iGotBodyData;
       
   324 
       
   325 	/** A descriptor pointer to a buffer containing the current request body 
       
   326 		data part.
       
   327 	*/
       
   328 	//##ModelId=3C4C41A702C4
       
   329 	TPtrC8					iDataPart;
       
   330 
       
   331 	/** The overall size of the body data. If this is not known, e.g. the 
       
   332 		resquest is divided over several primitives, then this is set to 
       
   333 		KErrNotFound.
       
   334 	*/
       
   335 	//##ModelId=3C4C41A702B8
       
   336 	TInt					iOverallDataSize;
       
   337 
       
   338 	/** The remaining server SDU space for the current primitive.
       
   339 	*/
       
   340 	//##ModelId=3C4C41A702A6
       
   341 	TUint32					iRemainingSDUSpace;
       
   342 
       
   343 	/** The remaining server message space.
       
   344 	*/
       
   345 	//##ModelId=3C4C41A7029A
       
   346 	TUint32					iRemainingMessageSpace;
       
   347 
       
   348 	/** A flag to indicate whether LDT is supported.
       
   349 	*/
       
   350 	//##ModelId=3C4C41A70287
       
   351 	TBool					iSupportLDT;
       
   352 
       
   353 	/** The length of the trailer header info.
       
   354 	*/
       
   355 	TUint32					iTrailerInfoLength;
       
   356 
       
   357 	/** A flag to indicate wether the Server Message is limited.
       
   358 	*/
       
   359 	TBool					iLimitedMessageSize;
       
   360 
       
   361 	};
       
   362 
       
   363 #endif	// __CWSPCOTXDATA_H__