applayerpluginsandutils/httpprotocolplugins/WspProtocolHandler/CWspCOTransaction.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 __CWSPCOTRANSACTION_H__
       
    17 #define __CWSPCOTRANSACTION_H__
       
    18 
       
    19 // System includes
       
    20 #include <e32base.h>
       
    21 #include <wsp/mwspcomethodcallback.h>
       
    22 #include <wsp/wsptypes.h>
       
    23 #include <http/framework/cprottransaction.h>
       
    24 #include <http/framework/httplogger.h>
       
    25 
       
    26 // User includes
       
    27 #include "mwspprimitivesendercallback.h"
       
    28 #include "mwspcorxdatacallback.h"
       
    29 #include "mwspcotxdatacallback.h"
       
    30 #include "cwspheaderutils.h"
       
    31 
       
    32 // Forward declarations
       
    33 class MWspCapabilityViewer;
       
    34 class MWspCOMethodInvoker;
       
    35 class CWspPrimitiveSender;
       
    36 class MWspCOMethodObserver;
       
    37 
       
    38 // Types used for arguments in this file (e.g. TWspBearer) are from the Wap namespace
       
    39 using namespace Wap;
       
    40 
       
    41 // @todo docing
       
    42 
       
    43 //##ModelId=3BBD80610048
       
    44 class CWspCOTransaction : public CProtTransaction, public MWspCOMethodCallback,
       
    45 												   public MWspPrimitiveSenderCallback,
       
    46 												   public MWspCORxDataCallback,
       
    47 												   public MWspCOTxDataCallback
       
    48 	{
       
    49 public:	// Methods
       
    50 
       
    51 /**	@fn				NewL(RHTTPTransaction aTransaction, MWspCOMethodInvoker& aMethodInvoker, MWspCapabilityViewer& aNegotiatedCapInfo, CWspHeaderUtils& aHdrUtils)
       
    52 	Intended Usage	:	Static factory constructor.
       
    53 	@since			7.0
       
    54 	@leave			Leaves with KErrNoMemory if there was not enough memory to
       
    55 					create the object.
       
    56 	@param			aTransaction		The HTTP transaction object associated
       
    57 										with this WSP method transaction.
       
    58 	@param			aMethodInvoker		A reference to the method invoker object.
       
    59 	@param			aNegotiatedCapInfo	A reference to the negotiated capability
       
    60 										info.
       
    61 	@param			aObserver			A reference to the method observer.
       
    62 	@param			aHdrUtils			A reference to the WSP header utilities
       
    63 	@return			A pointer to newly created object.
       
    64 */
       
    65 	//##ModelId=3C4C41A3032A
       
    66 	static CWspCOTransaction* NewL(
       
    67 								   RHTTPTransaction			aTransaction, 
       
    68 								   MWspCOMethodInvoker&		aMethodInvoker, 
       
    69 								   MWspCapabilityViewer&	aNegotiatedCapInfo,
       
    70 								   MWspCOMethodObserver&	aObserver,
       
    71 								   CWspHeaderUtils&			aHdrUtils
       
    72 								   );
       
    73 
       
    74 /** @fn				~CWspCOTransaction()
       
    75 	Intended Usage	:	Standard destructor.
       
    76 	@since			7.0
       
    77 */
       
    78 	//##ModelId=3C4C41A3030C
       
    79 	~CWspCOTransaction();
       
    80 
       
    81 /**	@fn				InitRequestL()
       
    82 
       
    83 	@since			7.0
       
    84 */
       
    85 	void InitRequestL();
       
    86 
       
    87 /**	@fn				NotifyMoreRequestData()
       
    88 
       
    89 	@since			7.0
       
    90 */
       
    91 	void NotifyMoreRequestData();
       
    92 
       
    93 /**	@fn				AbortRequest()
       
    94 
       
    95 	@since			7.0
       
    96 */
       
    97 	void AbortRequest();
       
    98 
       
    99 /**	@fn				Suicide()
       
   100 	Intended Usage	:	The client has closed the RHTTPTransaction that this 
       
   101 						object wraps. The protocol base base class has also 
       
   102 						transferred ownership of this object to the sub-class, 
       
   103 						the WSP protocol handler. This function ensures cleanup
       
   104 						of this object. If the WSP method transaction was in 
       
   105 						the Null state, then the object deletes itself. If the 
       
   106 						WSP method transaction is in the Aborting state, then 
       
   107 						the object will delete itself once it receives the 
       
   108 						S-MethodAbort.ind primitive.
       
   109 	@since			7.0
       
   110 	@todo			finish docing
       
   111 	@pre			The client has closed the RHTTPTransaction that this object
       
   112 					wraps.
       
   113 	@post			If the WSP method transaction was in the Null state, then 
       
   114 					the object has deleted itself. If the WSP method transaction
       
   115 					is in the Aborting state, then the object will delete itself
       
   116 					once it receives the S-MethodAbort.ind primitive.
       
   117 */
       
   118 	//##ModelId=3C4C41A3029E
       
   119 	void Suicide();
       
   120 
       
   121 /**	@fn				GetWspHeaderUtils() const
       
   122 	Intended Usage	:	This method provides access to the WSP header utilities.
       
   123 	@since			7.0
       
   124 	@return			A reference to the WSP header utilities
       
   125 */
       
   126 	//##ModelId=3C4C41A30276
       
   127 	CWspHeaderUtils& GetWspHeaderUtils() const;
       
   128 
       
   129 private:	// Methods from CProtTransaction
       
   130 
       
   131 /**	@fn				CreateTxDataL()
       
   132 	@see			CProtTransaction
       
   133 */
       
   134 	//##ModelId=3C4C41A3023A
       
   135 	virtual void CreateTxDataL();
       
   136 
       
   137 /**	@fn				CreateRxDataL(MRxDataObserver& aObserver)
       
   138 	@see			CProtTransaction
       
   139 */
       
   140 	//##ModelId=3C4C41A301D5
       
   141 	virtual void CreateRxDataL(MRxDataObserver& aObserver);
       
   142 
       
   143 private:	// Methods from MWspCOMethodCallback
       
   144 
       
   145 /** @fn				MethodInvokeCnf()
       
   146 	@see			MWspCOMethodCallback
       
   147 */
       
   148 	//##ModelId=3C4C41A30199
       
   149 	virtual void MethodInvokeCnf();
       
   150 
       
   151 /** @fn				MethodInvokeDataCnf()
       
   152 	@see			MWspCOMethodCallback
       
   153 */
       
   154 	//##ModelId=3C4C41A30059
       
   155 	virtual void MethodInvokeDataCnf();
       
   156 
       
   157 /** @fn				MethodAbortInd(TWSPReason aReason)
       
   158 	@see			MWspCOMethodCallback
       
   159 */
       
   160 	//##ModelId=3C4C41A203E7
       
   161 	virtual void MethodAbortInd(TWspReason aReason);
       
   162 
       
   163 /** @fn				MethodResultInd(TInt aStatus, const TDesC8& aResponseHeaders, MHTTPDataSupplier& aResponseBody, TBool aMoreData)
       
   164 	@see			MWspCOMethodCallback
       
   165 */
       
   166 	//##ModelId=3C4C41A2033D
       
   167 	virtual void MethodResultInd(
       
   168 								TInt					aStatus, 
       
   169 								const TDesC8&			aResponseHeaders, 
       
   170 								MHTTPDataSupplier&		aResponseBody,
       
   171 								TBool					aMoreData
       
   172 								);
       
   173 
       
   174 /** @fn				MethodResultDataInd(const TDesC8& aTrailerHeaders, TBool aMoreData)
       
   175 	@see			MWspCOMethodCallback
       
   176 */
       
   177 	//##ModelId=3C4C41A202EC
       
   178 	virtual void MethodResultDataInd(const TDesC8& aTrailerHeaders, TBool aMoreData);
       
   179 
       
   180 private:	// Methods from MWspPrimitiveSenderCallback
       
   181 
       
   182 /**	@fn				SendPrimitiveL(TWspPrimitive aPrimitive)
       
   183 	@see			MWspPrimitiveSenderCallback
       
   184 */
       
   185 	//##ModelId=3C4C41A2029C
       
   186 	virtual void SendPrimitiveL(TWspPrimitive aPrimitive);
       
   187 
       
   188 /** @fn				WspPrimitiveSenderCallbackError(TInt aError)
       
   189 	@see			MWspPrimitiveSenderCallback
       
   190 */
       
   191 	//##ModelId=3C4C41A20256
       
   192 	virtual TInt WspPrimitiveSenderCallbackError(TInt aError);
       
   193 
       
   194 private:	// Methods from MWspCORxDataCallback
       
   195 
       
   196 /**	@fn				AbortResponse()
       
   197 	@see			MWspCORxDataCallback
       
   198 */
       
   199 	//##ModelId=3C4C41A20210
       
   200 	virtual void AbortResponse();
       
   201 
       
   202 /**	@fn				SendResponsePrimitive()
       
   203 	@see			MWspCORxDataCallback
       
   204 */
       
   205 	//##ModelId=3C4C41A201F2
       
   206 	virtual void SendResponsePrimitive();
       
   207 
       
   208 private:	// Methods from MWspCOTxDataCallback
       
   209 
       
   210 /**	@fn				SendInvokePrimitive()
       
   211 	Informs the Tx Data object observer that it should send a S-MethodInvoke or
       
   212 	S-MethodInvokeData primitive.
       
   213 	@since			7.0
       
   214 */
       
   215 	virtual void SendInvokePrimitive();
       
   216 
       
   217 /**	@fn				AbortInvoke()
       
   218 	Informs the Tx Data object observer that the method should be aborted.
       
   219 	@see			7.0
       
   220 */
       
   221 	virtual void AbortInvoke();
       
   222 
       
   223 private:	// Methods
       
   224 
       
   225 /**	@fn				CWspCOTransaction(RHTTPTransaction aTransaction, MWspCOMethodInvoker& aMethodInvoker, MWspCapabilityViewer& aNegotiatedCapInfo, CWspHeaderUtils& aHdrUtils)
       
   226 	Intended Usage	:	First phase constructor.
       
   227 	@since			7.0
       
   228 	@param			aTransaction		The HTTP transaction object associated
       
   229 										with this WSP method transaction.
       
   230 	@param			aMethodInvoker		A reference to the method invoker object.
       
   231 	@param			aNegotiatedCapInfo	A reference to the negotiated capability
       
   232 										info.
       
   233 	@param			aObserver			A reference to the method observer.
       
   234 	@param			aHdrUtils			A reference to the WSP header utilities
       
   235 */
       
   236 	//##ModelId=3C4C41A20120
       
   237 	CWspCOTransaction(
       
   238 					  RHTTPTransaction			aTransaction, 
       
   239 					  MWspCOMethodInvoker&		aMethodInvoker, 
       
   240 					  MWspCapabilityViewer&		aNegotiatedCapInfo,
       
   241 					  MWspCOMethodObserver&		aObserver,
       
   242 					  CWspHeaderUtils&			aHdrUtils
       
   243 					  );
       
   244 
       
   245 /**	@fn				ConstructL()
       
   246 	Intended Usage	:	Second phase constructor. Does any necessary allocations.
       
   247 	@since			7.0
       
   248 	@pre			First phase construction has been done.
       
   249 	@post			The object is fully initialised.
       
   250 */
       
   251 	//##ModelId=3C4C41A20116
       
   252 	void ConstructL();
       
   253 
       
   254 /**	@fn				MethodInvoke()
       
   255 	Intended Usage	:	Invokes the method. Sends the S-MethodInvoke.req 
       
   256 						primitive. Ensures that the Server SDU size and the
       
   257 						Server message size are observed. Will leave if either
       
   258 						of these session capabilities are exceeded.
       
   259 	@since			7.0
       
   260 	@pre			The WSP method transaction is in the Null state.
       
   261 	@post			The S-MethodInvoke.req primitive has been sent and the WSP
       
   262 					method transaction is in the Requesting state.
       
   263 */
       
   264 	//##ModelId=3C4C41A302F8
       
   265 	void MethodInvoke();
       
   266 
       
   267 /**	@fn				MethodInvokeData()
       
   268 	Intended Usage	:
       
   269 	@since			7.0
       
   270 	@todo			finish docing
       
   271 	@pre			The WSP method transaction is in the Requesting state.
       
   272 	@post			The S-MethodInvokeData.req primitive has been sent and the
       
   273 					WSP method transaction remains in the Requesting state.
       
   274 */
       
   275 	//##ModelId=3C4C41A302D0
       
   276 	void MethodInvokeData();
       
   277 
       
   278 /**	@fn				MethodAbort()
       
   279 	Intended Usage	:
       
   280 	@since			7.0
       
   281 	@todo			finish docing
       
   282 	@pre			The WSP method transaction is not in the Null or Aborting 
       
   283 					state.
       
   284 	@post			The S-MethodAbort.req primitive has been sent and the WSP
       
   285 					method transaction is in the Aborting state.
       
   286 */
       
   287 	//##ModelId=3C4C41A302BC
       
   288 	void MethodAbort();
       
   289 
       
   290 /**	@fn				MethodResultRes()
       
   291 	Intended Usage	:
       
   292 	@since			7.0
       
   293 	@post			The WSP method transaction is in the Waiting or Completing
       
   294 					state.
       
   295 	@pre			The WSP method transaction is in the Waiting2 state if the 
       
   296 					request response is not complete and there are subsequent 
       
   297 					S-MethodResultData primitives to be received. If the request
       
   298 					response is complete, then the WSP method transaction is in
       
   299 					the Null state.
       
   300 */
       
   301 	void MethodResultRes();
       
   302 
       
   303 /**	@fn				MethodResultDataRes()
       
   304 	Intended Usage	:
       
   305 	@since			7.0
       
   306 	@post			The WSP method transaction is in the Waiting2 or Completing
       
   307 					state.
       
   308 	@pre			The WSP method transaction remains in the Waiting2 state if 
       
   309 					the request response is not complete and there are 
       
   310 					subsequent S-MethodResultData primitives to be received. If
       
   311 					the request response is complete, then the WSP method 
       
   312 					transaction is in the Null state.
       
   313 */
       
   314 	void MethodResultDataRes();
       
   315 
       
   316 /**	@fn				ProcessResponseDataL(const TDesC8& aResponseHeaders, MHTTPDataSupplier& aResponseBody, TBool aMoreData)	
       
   317 
       
   318 	@since			7.0
       
   319 	@param			aResponseHeaders	A reference to a buffer	that provides 
       
   320 										the encoded response headers.
       
   321 	@param			aResponseBody		A reference to a data supplier object
       
   322 										that provides the data associated 
       
   323 										with the response.
       
   324 	@param			aMoreData			A flag to indicate whether subsequent
       
   325 										S-MethodResultData primitives are to be
       
   326 										received for this transaction.
       
   327 */
       
   328 	void ProcessResponseDataL(const TDesC8& aResponseHeaders, MHTTPDataSupplier& aResponseBody, TBool aMoreData);
       
   329 
       
   330 /**	@fn				void PostResProcessing()
       
   331 	Does the necessary processing given that either a S-MethodResult.res or a
       
   332 	S-MethodResultData.res primitive has just been sent. If the method state is
       
   333 	Completing, then the method moves into the Null state, and if the self-
       
   334 	destruction has been flagged, the object deletes itself. If the method is
       
   335 	not in the Completing state, then it is in the Waiting2 state, and it does
       
   336 	not change state.
       
   337 	@since			7.0
       
   338 	@pre			The method is in either the Completing or the Waiting2 state.
       
   339 	@post			The method is in either in the Null state or has remained in 
       
   340 					the Waiting2 state.
       
   341 */
       
   342 	void PostResProcessing();
       
   343 
       
   344 /**	@fn				ResetFlags()
       
   345 	Intended Usage	:	Resets all the flags in the object.
       
   346 	@since			7.0
       
   347 	@post			All flags are set to EFalse.
       
   348 */
       
   349 	//##ModelId=3C4C41A20057
       
   350 	void ResetFlags();
       
   351 
       
   352 private:	// Attributes
       
   353 
       
   354 	/** HTTP logger handle (debug only)
       
   355 	*/
       
   356 	__DECLARE_LOG
       
   357 
       
   358 	/** A reference to the CO Transaction Invoker object. Owned by the transport 
       
   359 		handler.
       
   360 	*/
       
   361 	//##ModelId=3C4C41A2004D
       
   362 	MWspCOMethodInvoker&		iMethodInvoker;
       
   363 
       
   364 	/** An object that holds the negotiated capabilties for the current Wsp 
       
   365 		session.
       
   366 	*/
       
   367 	//##ModelId=3C4C41A20039
       
   368 	MWspCapabilityViewer&		iNegotiatedCapInfo;
       
   369 
       
   370 	/** A reference to the method observer.
       
   371 	*/
       
   372 	//##ModelId=3C4C41A20025
       
   373 	MWspCOMethodObserver&		iObserver;
       
   374 
       
   375 	/** A reference to the WSP header utilities
       
   376 	*/
       
   377 	//##ModelId=3C4C438001E5
       
   378 	CWspHeaderUtils&			iHdrUtils;
       
   379 
       
   380 	/** The state of the WSP method transaction.
       
   381 	*/
       
   382 	//##ModelId=3C4C41A20007
       
   383 	TWspMethodState				iMethodState;	
       
   384 
       
   385 	/** A flag to indicate whether there is more data to send in subsequent
       
   386 		S-MethodInvokeData primitives.
       
   387 	*/
       
   388 	//##ModelId=3C4C41A103DB
       
   389 	TBool						iMoreRequestData;
       
   390 
       
   391 	/** A flag to incidcate whether the S-MethodResult.res primitive has been sent.
       
   392 	*/
       
   393 	TBool						iSentMethodResultRes;
       
   394 
       
   395 	/** A flag to indicate whether the client aborted the method.
       
   396 	*/
       
   397 	//##ModelId=3C4C41A1039F
       
   398 	TBool						iClientMethodAbort;
       
   399 
       
   400 	/** A flag that inducates whether the final S-MethodResult.res or 
       
   401 		S-MethodResultData.res primitive is waiting to be sent.
       
   402 	*/
       
   403 	TBool						iFinalResPending;
       
   404 
       
   405 	/** A flag to indicate that the client has closed the transaction and that
       
   406 		once the S-MethodAbort.ind primitive is received, the object must self-
       
   407 		destruct.
       
   408 	*/
       
   409 	//##ModelId=3C4C41A10383
       
   410 	TBool						iSuicide;
       
   411 
       
   412 	/** An active object that is used to invoke the sending of certain WSP
       
   413 		primitives.
       
   414 	*/
       
   415 	//##ModelId=3C4C41A10377
       
   416 	CWspPrimitiveSender*		iPrimitiveSender;
       
   417 
       
   418 	};
       
   419 
       
   420 #endif	// __CWSPCOTRANSACTION_H__