applayerprotocols/httpexamples/nwsswsptrhnd/CNwssWspCOEventDispatcher.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 /**
       
    17  @file CNwssWspCOEventDispatcher.h
       
    18  @warning : This file contains Rose Model ID comments - please do not delete
       
    19 */
       
    20 
       
    21 #ifndef	__CNWSSWSPCOEVENTDISPATCHER_H__
       
    22 #define __CNWSSWSPCOEVENTDISPATCHER_H__
       
    23 
       
    24 // System includes
       
    25 #include <e32base.h>
       
    26 #include <wapcli.h>
       
    27 
       
    28 
       
    29 // Forward declarations
       
    30 class MNwssSessionEventHandler;
       
    31 class MNwssTransactionEventHandler;
       
    32 class MNwssOomHandler;
       
    33 
       
    34 /**
       
    35 	@since			7.0
       
    36 	This class acts as a hub for the receipt of Connection-Oriented WSP session and
       
    37 	transaction events.  It is an Active Object, and each time the method ::Start()
       
    38 	is called, it requests an event from the NWSS WAP Stack.  Upon completion of
       
    39 	the request, the incoming event is examined, and its type (session or
       
    40 	transaction) is determined. A call-back method appropriate to the event type is
       
    41 	called on either the MNwssTransactionEventHandler or MNwssSessionEventHandler
       
    42 	interfaces that 'observes' the object.  In the case of transaction events, the
       
    43 	NWSS WAP Stack's transaction handle (a RWSPCOTrans object) is passed through
       
    44 	along with the event.
       
    45  */
       
    46 
       
    47 //##ModelId=3BBD8CBA0288
       
    48 class CNwssWspCOEventDispatcher : public CActive
       
    49 	{
       
    50 public: // methods
       
    51 
       
    52 /** 
       
    53     Factory construction of CNwssWspCOEventDispatcher.
       
    54 	@since			7.0
       
    55 	@param			aWspSession		(in) The caller's Wap Stack CO WSP session handle.
       
    56 	@param			aSessEventHnd	(in) An interface to be used for notifications
       
    57 										 of received session events.
       
    58 	@param			aTransEventHnd	(in) An interface to be used for notifications
       
    59 										 of received transaction events.
       
    60 	@param			aOutOfMemoryHnd	(in) An interface to be used in the event of OOM occurring
       
    61 										 whilst the session or transaction event handlers were
       
    62 										 handling a WAP stack event.
       
    63 	@return			The newly constructed CNwssWspCOEventDispatcher instance.
       
    64 	@leave			System error codes, e.g. KErrNoMemory.
       
    65  */
       
    66 	//##ModelId=3C4C49B90178
       
    67 	static CNwssWspCOEventDispatcher* NewL(RWSPCOConn& aWspSession,
       
    68 										   MNwssSessionEventHandler& aSessEventHnd,
       
    69 										   MNwssTransactionEventHandler& aTransEventHnd,
       
    70 										   MNwssOomHandler& aOutOfMemoryHnd);
       
    71 
       
    72 /**
       
    73 	Destructor.
       
    74 	@since			7.0
       
    75  */
       
    76 	//##ModelId=3C4C49B900E2
       
    77 	virtual ~CNwssWspCOEventDispatcher();
       
    78 
       
    79 /**
       
    80 	Start waiting for stack events.  The dispatcher goes active,
       
    81 					and will repeatedly request events from the WAP Stack, until
       
    82 					it is subsequently cancelled.
       
    83 	@since			7.0
       
    84  */
       
    85 	//##ModelId=3C4C49B9007D
       
    86 	void Start();
       
    87 
       
    88 private: // methods from CActive
       
    89 
       
    90 /** 
       
    91 		Called when the active object fires, ie. its asynchronous
       
    92 					request has completed
       
    93 	@since			7.0
       
    94 	@leave			System error codes, e.g. KErrNoMemory and internal error codes
       
    95 					generated for WTLS handshake failures, see <wsperror.h>
       
    96  */
       
    97 	//##ModelId=3C4C49B803BB
       
    98 	virtual void RunL();
       
    99 
       
   100 /**
       
   101 		Called if RunL leaves, to allow the AO to handle the error before
       
   102 					the scheduler does
       
   103 	@since			7.0
       
   104 	@param			aError	(in) The error code to be handled, which RunL() left with
       
   105 	@return			A final error code, should aError not have been handled, which the
       
   106 					active scheduler handles.
       
   107  */
       
   108 	//##ModelId=3C4C49B8025D
       
   109 	virtual TInt RunError(TInt aError);
       
   110 
       
   111 /**
       
   112 		Cancellation protocol for the active object.  It cancels the
       
   113 					request GetNextEvent() request it keeps outstanding with the
       
   114 					WAP Stack.
       
   115 	@since			7.0
       
   116  */
       
   117 	//##ModelId=3C4C49B801B2
       
   118 	virtual void DoCancel();
       
   119 
       
   120 private: // methods
       
   121 
       
   122 /**
       
   123 	Normal constructor.  Keeps references to the supplied arguments.
       
   124 	@since			7.0
       
   125 	@param			aWspSession		(in) The caller's Wap Stack CO WSP session handle.
       
   126 	@param			aSessEventHnd	(in) An interface to be used for notifications
       
   127 										 of received session events.
       
   128 	@param			aTransEventHnd	(in) An interface to be used for notifications
       
   129 										 of received transaction events.
       
   130 	@param			aOutOfMemoryHnd	(in) An interface to be used in the event of OOM occurring
       
   131 										 whilst the session or transaction event handlers were
       
   132 										 handling a WAP stack event.  
       
   133  */
       
   134 	//##ModelId=3C4C49B70324
       
   135 	CNwssWspCOEventDispatcher(RWSPCOConn& aWspSession,
       
   136 							  MNwssSessionEventHandler& aSessEventHnd,
       
   137 							  MNwssTransactionEventHandler& aTransEventHnd,
       
   138 							  MNwssOomHandler& aOutOfMemoryHnd);
       
   139 
       
   140 private: // attributes
       
   141 
       
   142 	/** The WSP Session handle.  This is not owned, opened or closed in this class.
       
   143 	*/
       
   144 	//##ModelId=3C4C49B702AD
       
   145 	RWSPCOConn& iWspSession;
       
   146 
       
   147 	/** Handler for session events received at the dispatcher.
       
   148 	*/
       
   149 	//##ModelId=3C4C49B702A1
       
   150 	MNwssSessionEventHandler& iSessEventHnd;
       
   151 
       
   152 	/** Handler for transaction events received at the dispatcher.
       
   153 	*/
       
   154 	//##ModelId=3C4C49B7028D
       
   155 	MNwssTransactionEventHandler& iTransEventHnd;
       
   156 
       
   157 	/** Handler for out-of-memory situations.
       
   158 	*/
       
   159 	//##ModelId=3C9B09460197
       
   160 	MNwssOomHandler& iOutOfMemoryHnd;
       
   161 
       
   162 	/** The event that has occured
       
   163 	*/
       
   164 	//##ModelId=3C4C49B70279
       
   165 	RWSPCOConn::TEvent iWspEvent;
       
   166 
       
   167 	/** The transaction handle on which transaction events occur
       
   168 	*/
       
   169 	//##ModelId=3C4C49B70215
       
   170 	RWSPCOTrans iTransaction;
       
   171 
       
   172 	/** The ID of the last transaction on which an event was received
       
   173 	*/
       
   174 	//##ModelId=3C9B09460183
       
   175 	RWSPCOTrans::TTransID iTrId;
       
   176 	};
       
   177 
       
   178 
       
   179 #endif // __CNWSSWSPCOEVENTDISPATCHER_H__