applayerpluginsandutils/httpprotocolplugins/WspProtocolHandler/CWspCOProtocolHandler.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	__CWSPCOPROTOCOLHANDLER_H__
       
    17 #define __CWSPCOPROTOCOLHANDLER_H__
       
    18 
       
    19 // System includes
       
    20 #include <e32base.h>
       
    21 #include <http/framework/cprotocolhandler.h>
       
    22 #include <wsp/mwspcosessioncallback.h>
       
    23 #include <wsp/mwspcapabilityprovider.h>
       
    24 #include <wsp/mwspsessionheadersprovider.h>
       
    25 
       
    26 // User includes
       
    27 #include "mconnectiontimercallback.h"
       
    28 #include "mwspprimitivesendercallback.h"
       
    29 #include "mwspcomethodobserver.h"
       
    30 
       
    31 // Forward declarations
       
    32 class CWspCapabilityInfo;
       
    33 class CWspProxyInfoProvider;
       
    34 class CWspTransportHandler;
       
    35 class MWspCOSessionInvoker;
       
    36 class MWspCOMethodInvoker;
       
    37 class CConnectionTimer;
       
    38 class CWspPrimitiveSender;
       
    39 class CRxData;
       
    40 class CWspHeaderUtils;
       
    41 
       
    42 // @todo docing
       
    43 //##ModelId=3BBD7DB402C4
       
    44 class CWspCOProtocolHandler : public CProtocolHandler, public MWspCOSessionCallback,
       
    45 													   public MWspCapabilityProvider,
       
    46 													   public MWspSessionHeadersProvider,
       
    47 													   public MConnectionTimerCallback,
       
    48 													   public MWspPrimitiveSenderCallback,
       
    49 													   public MWspCOMethodObserver,
       
    50 													   public MProtHandlerInterface
       
    51 	{
       
    52 public:	// Methods
       
    53 
       
    54 /**	Static factory constructor.
       
    55 	@since			7.0
       
    56 	@leave			Leaves with KErrNoMemory if there was not enough memory to
       
    57 					create the object.
       
    58 	@param			aSession	A pointer to an RHTTPSession object.
       
    59 	@return			A pointer to newly created object.
       
    60 */
       
    61 	//##ModelId=3C4C439101F4
       
    62 	static CWspCOProtocolHandler* NewL(TAny* aSession);
       
    63 
       
    64 /** Standard destructor.
       
    65 	@since			7.0
       
    66 */
       
    67 	//##ModelId=3C4C439101D6
       
    68   ~CWspCOProtocolHandler();
       
    69 
       
    70 private:	// Methods from CProtocolHandler
       
    71 
       
    72 /** 
       
    73 	@see			CProtocolHandler
       
    74 */
       
    75 	//##ModelId=3C4C43910172
       
    76 	virtual void CreateCodecL();
       
    77 
       
    78 /** 
       
    79 	@see			CProtocolHandler
       
    80 */
       
    81 	//##ModelId=3C4C439100BD
       
    82 	virtual CProtTransaction* CreateProtTransactionL(RHTTPTransaction aTransaction);
       
    83 
       
    84 /** 
       
    85 	@see			CProtocolHandler
       
    86 */
       
    87 	//##ModelId=3C4C43910009
       
    88 	virtual TBool ServiceL(CProtTransaction& aTrans);
       
    89 
       
    90 /** 
       
    91 	@see			CProtocolHandler
       
    92 */
       
    93 	//##ModelId=3C4C4390033D
       
    94 	virtual void ClosedTransactionHook(CProtTransaction* aTrans);
       
    95 
       
    96 /** 
       
    97 	@see			CProtocolHandler
       
    98 */
       
    99 	//##ModelId=3C4C4390029D
       
   100 	virtual void CancelTransactionHook(CProtTransaction& aTransaction);
       
   101 
       
   102 /** 
       
   103 	@see			CProtocolHandler
       
   104 */
       
   105 	//##ModelId=3C4C439001F2
       
   106 	virtual void NotifyNewRequestBodyPart(CProtTransaction& aTransaction);
       
   107 
       
   108 	virtual void GetInterfaceL(TUid aInterfaceId, MProtHandlerInterface*& aInterfacePtr);
       
   109 
       
   110 	/** Get the Server Certificate for the current session.
       
   111 	@param	aServerCert A TCertInfo which will be filled with the certificate information
       
   112 	@return	An error code.  KErrNone if aServerCert has been completed, otherwise one of 
       
   113 			the system wide error codes
       
   114 	*/
       
   115 	TInt SessionServerCert(TCertInfo& aServerCert);
       
   116 
       
   117 	/** Get the Server Certificate for the specified transaction.  This function returns
       
   118 	KErrNotSupported because for WSP the certificate applies to the whole session.
       
   119 	@param	aServerCert A TCertInfo which will be filled with the certificate information
       
   120 	@param	aTransaction The transaction for which the certificate info is requested
       
   121 	@return	KErrNotSupported
       
   122 	*/
       
   123 	TInt TransactionServerCert(TCertInfo& aServerCert, RHTTPTransaction aTransaction);
       
   124 
       
   125 
       
   126 private:	// Methods from MHTTPFilterBase
       
   127 
       
   128 /**
       
   129 	@see			MHTTPFilterBase
       
   130 */
       
   131 	//##ModelId=3C4C43900152
       
   132 	virtual void MHFSessionRunL(const THTTPSessionEvent& aEvent);
       
   133 
       
   134 /**
       
   135 	@see			MHTTPFilterBase
       
   136 */
       
   137 	//##ModelId=3C4C43900076
       
   138 	virtual TInt MHFSessionRunError(TInt aError, const THTTPSessionEvent& aEvent);
       
   139 
       
   140 private:	// Methods from MWspCOSessionCallback
       
   141 
       
   142 /**
       
   143 	@see			MWspCOSessionCallback
       
   144 */
       
   145 	//##ModelId=3C4C43900026
       
   146 	virtual void ConnectCnf();
       
   147 
       
   148 /**
       
   149 	@see			MWspCOSessionCallback
       
   150 */
       
   151 	//##ModelId=3C4C438F03B4
       
   152 	virtual void ResumeCnf();
       
   153 
       
   154 /**
       
   155 	@see			MWspCOSessionCallback
       
   156 */
       
   157 	//##ModelId=3C4C438F0223
       
   158 	virtual void DisconnectInd(
       
   159 							  TWspReason				aReason, 
       
   160 							  TBool						aRedirectSecurity, 
       
   161 							  TWspRedirectedAddress&	aRedirectAddress, 
       
   162 							  const TDesC8&				aErrorHeader, 
       
   163 							  const TDesC8&				aErrorBody
       
   164 							  );
       
   165 
       
   166 /**
       
   167 	@see			MWspCOSessionCallback
       
   168 */
       
   169 	//##ModelId=3C4C438F0197
       
   170 	virtual void SuspendInd(TWspReason aReason);
       
   171 
       
   172 /**
       
   173 	@see			MWspCOSessionCallback
       
   174 */
       
   175 	//##ModelId=3C4C438F0115
       
   176 	virtual void ExceptionInd(const TDesC8& aExceptionData);
       
   177 
       
   178 private:	// Methods from MWspCapabilityProvider
       
   179 
       
   180 /**
       
   181 	@see			MWspCapabilityProvider		
       
   182 */
       
   183 	//##ModelId=3C4C438F00CF
       
   184 	virtual const MWspCapabilityViewer& ClientCapabilities() const;
       
   185 
       
   186 /**
       
   187 	@see			MWspCapabilityProvider		
       
   188 */
       
   189 	//##ModelId=3C4C438F0092
       
   190 	virtual MWspCapabilitySetter& ServerCapabilities() const;
       
   191 
       
   192 private:	// Methods from MWspSessionHeadersProvider
       
   193 
       
   194 /**
       
   195 	@see			MWspSessionHeadersProvider		
       
   196 */
       
   197 	//##ModelId=3C4C438F004C
       
   198 	virtual const TDesC8& ClientHeaders() const;
       
   199 
       
   200 /** 
       
   201 	@see			MWspSessionHeadersProvider		
       
   202 */
       
   203 	//##ModelId=3C4C438E03C6
       
   204 	virtual void SetServerHeadersL(const TDesC8& aBuffer);
       
   205 
       
   206 private:	// Methods from MConnectionTimerCallback
       
   207 
       
   208 /**
       
   209 	@see			MConnectionTimerCallback
       
   210 */
       
   211 	//##ModelId=3C4C438E038A
       
   212 	virtual void HandleConnectionTimedOut();
       
   213 
       
   214 private:	// Methods from MWspPrimitiveSenderCallback
       
   215 
       
   216 /**
       
   217 	@see			MWspPrimitiveSenderCallback
       
   218 */
       
   219 	//##ModelId=3C4C438E0326
       
   220 	virtual void SendPrimitiveL(TWspPrimitive aPrimitive);
       
   221 
       
   222 /**
       
   223 	@see			MWspPrimitiveSenderCallback
       
   224 */
       
   225 	//##ModelId=3C4C438E02C2
       
   226 	virtual TInt WspPrimitiveSenderCallbackError(TInt aError);
       
   227 
       
   228 private:	// Methods from MWspCOMethodObserver
       
   229 
       
   230 /**
       
   231 	@see			MWspCOMethodObserver
       
   232 */
       
   233 	//##ModelId=3C4C438E025E
       
   234 	virtual void HandleMethodAbort(CWspCOTransaction& aTransaction);
       
   235 
       
   236 /**
       
   237 	@see			MWspCOMethodObserver
       
   238 */
       
   239 	virtual void NotifyPendingCompletingMethod();
       
   240 
       
   241 /**
       
   242 	@see			MWspCOMethodObserver
       
   243 */
       
   244 	virtual void NotifyMethodComplete();
       
   245 
       
   246 private:	// Methods from MRxDataObserver, inherited via MWspCOMethodObserver
       
   247 
       
   248 /**
       
   249 	@see			MRxDataObserver
       
   250 */
       
   251 	//##ModelId=3C4C438E01DC
       
   252 	virtual void SetStatusL(CRxData& aRecv, TInt aStatus);
       
   253 
       
   254 private:	// Methods from MProtHandlerInterface
       
   255 
       
   256 	/** Get the Server Certificate for the specified transaction.  This function returns
       
   257 	NULL because for WSP the certificate applies to the whole session.
       
   258 	@return	NULL
       
   259 	*/
       
   260 	const CCertificate* SessionServerCert();
       
   261 
       
   262 
       
   263 	/** Get the Server Certificate for the current session.
       
   264 	@param	aTransaction The transaction for which the certificate is requested
       
   265 	@return	A pointer to CCertificate, or NULL if not found.
       
   266 	*/
       
   267 	const CCertificate* TransactionServerCert(RHTTPTransaction aTransaction);
       
   268 
       
   269 
       
   270 private:	// Methods
       
   271 
       
   272 /**
       
   273 	@since			7.0
       
   274 	@param			aSession	The HTTP session.
       
   275 */
       
   276 	//##ModelId=3C4C438E013B
       
   277 	CWspCOProtocolHandler(RHTTPSession aSession);
       
   278 
       
   279 /**
       
   280 	@since			7.0
       
   281 	@todo			leaves
       
   282 	@pre			First phase construction has been done.
       
   283 	@post			The object is fully initialised.
       
   284 */
       
   285 	//##ModelId=3C4C438E0127
       
   286 	void ConstructL();
       
   287 
       
   288 /**Initiates a session connection.
       
   289 	@since			7.0
       
   290 	@warning		This function will panic with KWspPanicSessionNotInValidState
       
   291 					if the WSP session cannot be connected.
       
   292 	@todo			leaves
       
   293 	@pre			The WSP session is in the Null state.
       
   294 	@post			The WSP session is in the Connecting state. The connection 
       
   295 					timer has been started.
       
   296 */
       
   297 	//##ModelId=3C4C438E0109
       
   298 	void SessionConnectL();
       
   299 
       
   300 /**Initiates a session resume.
       
   301 	@since			7.0
       
   302 	@warning		This function will panic with KWspPanicSessionNotInValidState
       
   303 					if the WSP session cannot be resumed.
       
   304 	@todo			leaves
       
   305 	@pre			The WSP session is in the Connected, Suspending or 
       
   306 					Suspended state. The Suspend Resume facility is supported
       
   307 					in this WSP session.
       
   308 	@post			The WSP session is in the Resuming state. The connection 
       
   309 					timer has been started.
       
   310 */
       
   311 	//##ModelId=3C4C438E00EB
       
   312 	void SessionResumeL();
       
   313 	
       
   314 /**The session should be disconnected.
       
   315 	@since			7.0
       
   316 	@warning		This function will panic with KWspPanicSessionNotInValidState
       
   317 					if the WSP session cannot be disconnected.
       
   318 	@todo			leaves
       
   319 	@pre			The WSP session is in the Connecting, Connected, Suspending,
       
   320 					Suspended, or Resuming state.
       
   321 	@post			The WSP session is in the Closing state. The connection 
       
   322 					timer has been cancelled.
       
   323 */
       
   324 	//##ModelId=3C4C438E00A5
       
   325 	void SessionDisconnect(TWspReason aReason);
       
   326 
       
   327 /**The session should be suspended.
       
   328 	@since			7.0
       
   329 	@warning		This function will panic with KWspPanicSessionNotInValidState
       
   330 					if the WSP session cannot be suspended.
       
   331 	@todo			leaves
       
   332 	@pre			The WSP session is in the Connected or Resuming state. The 
       
   333 					Suspend Resume facility is supported in this WSP session.
       
   334 	@post			The WSP session is in the Closing state. The connection 
       
   335 					timer has been cancelled.
       
   336 */
       
   337 	//##ModelId=3C4C438E0087
       
   338 	void SessionSuspend();
       
   339 
       
   340 /**Processes the session connected event.
       
   341 	@since			7.0
       
   342 	@pre			
       
   343 	@post			
       
   344 */
       
   345 	//##ModelId=3C4C438E0073
       
   346 	void DoSessionConnectedL();
       
   347 
       
   348 /**Processes the session connected event, this is a non-leaving
       
   349 						method of DoSessionConnectedL()
       
   350 	@since			7.0
       
   351 	@pre			
       
   352 	@post			
       
   353 */
       
   354 	void DoSessionConnected();
       
   355 
       
   356 /**	@since			7.0
       
   357 	@todo			docing
       
   358 	@param			aEvent	The session event to send.
       
   359 	@pre
       
   360 	@post
       
   361 */
       
   362 	//##ModelId=3C4C438E0037
       
   363 	void SendSessionEvent(THTTPSessionEvent aEvent);
       
   364 
       
   365 /**@since			7.0
       
   366 	@todo			docing
       
   367 	@leave			Leaves with KErrNotFound if the WSP transport handler cannot
       
   368 					be found. Leaves with KErrNotSupported if the loaded WSP
       
   369 					transport handler does not support Connection-Orientated 
       
   370 					Session Management facility and Method Invocation facility.
       
   371 	@post			The
       
   372 */
       
   373 	//##ModelId=3C4C438D03BB
       
   374 	void CreateWspTransportHandlerL();
       
   375 
       
   376 /**Updates the client session headers that is supplied to 
       
   377 						the transport handler
       
   378 	@since			7.0
       
   379 	@leave			Leaves with KErrNoMemory if the header buffer cannot be 
       
   380 					created.
       
   381 	@post			The client session headers buffer is upto date.
       
   382 */
       
   383 	//##ModelId=3C4C438D039D
       
   384 	void UpdateClientSessionHeadersL();
       
   385 
       
   386 /**Checks the properties in the HTTP session for any client
       
   387 						proposed capablities and a specified connection time-out
       
   388 						value.
       
   389 	@since			7.0
       
   390 	@post			The client proposed capabilities and the connection time-out
       
   391 					value have been updated.
       
   392 */
       
   393 	//##ModelId=3C4C438D0389
       
   394 	void CheckClientCapabilities();
       
   395 
       
   396 /**Checks the client-requested capabilities against the 
       
   397 						corresponding negotiated capabilities to see if they 
       
   398 						have been reduced or denied.
       
   399 	@since			7.0
       
   400 	@todo			leaves
       
   401 	@return			A boolean value of ETrue if one or more of the client-
       
   402 					requested capabilities have been reduced or denied.
       
   403 	@pre			The negotiated capabilities have been passed up from the
       
   404 					transport handler. The S-Connect.cnf primitive has been
       
   405 					received.
       
   406 	@post			If any of the client-requested capabilities have been 
       
   407 					reduced or rejected, the session property representing that
       
   408 					capabililty is set the appropriate negotiated value.
       
   409 */
       
   410 	//##ModelId=3C4C438D0375
       
   411 	TBool UpdateNegotiatedCapabilitiesL();
       
   412 
       
   413 /**
       
   414 	Handles the receipt of a EConnect session event. Will inform the client if
       
   415 	the WSP session is not in the appropriate state to receive this event.
       
   416 	@since			7.0
       
   417 	@leave		This function will leave if the session connect/resume fails.
       
   418 */
       
   419 	//##ModelId=3C4C438D0361
       
   420 	void HandleConnectRequestL();
       
   421 
       
   422 /**
       
   423 	Handles the receipt of a EDisconnect session event. Will inform the client if
       
   424 	the WSP session is not in the appropriate state to receive this event.
       
   425 	@since			7.0
       
   426 */
       
   427 	//##ModelId=3C4C438D034D
       
   428 	void HandleDisconnectRequest();
       
   429 
       
   430 /**
       
   431 	Checks to see if a method is waiting. If so it sets the base class active
       
   432 	so that the next pending transaction gets serviced.
       
   433 	@since			7.0
       
   434 */
       
   435 	//##ModelId=3C4C438D0339
       
   436 	void CheckWaitingMethod();
       
   437 
       
   438 /**
       
   439 	Indicates if the Suspend Resume facility is supported by
       
   440 						the WSP session.
       
   441 	@since			7.0
       
   442 	@return			A boolean value of ETrue if the WSP session can support the 
       
   443 					Suspend Resume facility.
       
   444 */
       
   445 	//##ModelId=3C4C438D0325
       
   446 	TBool SupportSuspendResume() const;
       
   447 
       
   448 /**Indicates whether the WSP session can be resumed. The 
       
   449 						Suspend Resume facility must be supported and the WSP
       
   450 						session must in the Connected, Suspending or Suspended
       
   451 						state.
       
   452 	@since			7.0
       
   453 	@return			A boolean value of ETrue if the WSP session can be resumed.
       
   454 */
       
   455 	//##ModelId=3C4C438D0311
       
   456 	TBool CanResume() const;
       
   457 
       
   458 /**Indicates whether the WSP session can be suspended. The
       
   459 						Suspend Resume facility must be supported and the WSP
       
   460 						session must in the Connected or Resuming state.
       
   461 	@since			7.0
       
   462 	@return			A boolean value of ETrue if the WSP session can be suspended.
       
   463 */
       
   464 	//##ModelId=3C4C438D02F2
       
   465 	TBool CanSuspend() const;
       
   466 
       
   467 /**Resets the state of the protocol handler to that upon
       
   468 						initial construction, without changing the transport
       
   469 						handler.  This is NOT a published mechanism!
       
   470 	@since			7.0
       
   471 */
       
   472 	//##ModelId=3C4C438D02E8
       
   473 	void ResetAll();
       
   474 
       
   475 private:	// Attributes
       
   476 
       
   477 	/** A pointer to the Wsp Transport Handler.
       
   478 	*/
       
   479 	//##ModelId=3C4C438D02CA
       
   480 	CWspTransportHandler*		iTransportHandler;
       
   481 
       
   482 	/** A pointer to the CO Session Invoker object. Owned by the transport 
       
   483 		handler.
       
   484 	*/
       
   485 	//##ModelId=3C4C438D02B6
       
   486 	MWspCOSessionInvoker*		iSessionInvoker;
       
   487 
       
   488 	/** An object that holds the negotiated capabilties for the current Wsp 
       
   489 		session.
       
   490 	*/
       
   491 	//##ModelId=3C4C438D02A2
       
   492 	CWspCapabilityInfo*			iNegotiatedCapInfo;
       
   493 
       
   494 	/** An object that holds the proposed client capabilities.
       
   495 	*/
       
   496 	//##ModelId=3C4C438D0284
       
   497 	CWspCapabilityInfo*			iClientCapInfo;
       
   498 
       
   499 	/** A pointer to the proxy info provider.
       
   500 	*/
       
   501 	//##ModelId=3C4C438D0272
       
   502 	CWspProxyInfoProvider*		iProxyInfoProvider;
       
   503 
       
   504 	/** The state of the WSP session.
       
   505 	*/
       
   506 	//##ModelId=3C4C438D0266
       
   507 	TWspSessionState			iSessionState;
       
   508 
       
   509 	/** The connection timed-out value in microseconds. The protocol handler 
       
   510 		will abort a session connect after this time if a connection has not 
       
   511 		been established.
       
   512 	*/
       
   513 	//##ModelId=3C4C438D0252
       
   514 	TInt						iTimedOutValue;
       
   515 
       
   516 	/** A pointer to the connection timed-out timer.
       
   517 	*/
       
   518 	//##ModelId=3C4C438D023E
       
   519 	CConnectionTimer*			iConnectionTimer;
       
   520 
       
   521 	/** An active object that is used to invoke the sending of certain WSP
       
   522 		primitives.
       
   523 	*/
       
   524 	//##ModelId=3C4C438D022A
       
   525 	CWspPrimitiveSender*		iPrimitiveSender;
       
   526 
       
   527 	/** A buffer holding the encoded client session headers.
       
   528 	*/
       
   529 	//##ModelId=3C4C438D0218
       
   530 	HBufC8*						iClientSessionHeaders;
       
   531 
       
   532 	/** A flag indicating that a session connect or resume has timed-out.
       
   533 	*/
       
   534 	//##ModelId=3C4C438D020C
       
   535 	TBool						iConnectTimedOut;
       
   536 
       
   537 	/** A flag indicating that there is a method transaction waiting to be 
       
   538 		serviced.
       
   539 	*/
       
   540 	//##ModelId=3C4C438D01F8
       
   541 	TBool						iWaitingMethod;
       
   542 
       
   543 	/** A pointer to the WSP header utils
       
   544 	*/
       
   545 	//##ModelId=3C4C438D01E4
       
   546 	CWspHeaderUtils*			iHdrUtils;
       
   547 
       
   548 	/** The number of methods in Completing state waiting to send the final .res
       
   549 		primitive.
       
   550 	*/
       
   551 	TInt						iPendingCompletingMethods;
       
   552 
       
   553 	/** A flag indicating that the client has requested a disconnect.
       
   554 	*/
       
   555 	TBool						iDisconnectRequested;
       
   556 
       
   557 	};
       
   558 
       
   559 #endif	// __CWSPCOPROTOCOLHANDLER_H__