natplugins/natpnatfwsdpprovider/inc/nspevents.h
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Events for NAT FW SDP Providers state machines
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef NSPEVENTS_H
       
    19 #define NSPEVENTS_H
       
    20 
       
    21 #include "mnatfwconnectivityobserver.h"
       
    22 
       
    23 class CSdpDocument;
       
    24 class CNSPSession;
       
    25 
       
    26 /**
       
    27  * Class encapsulates callback information for session observer.
       
    28  * Execution of observer callbacks must be done by Controller - object
       
    29  * due to possible synchronous closing, and the following stack unwind.
       
    30  * 
       
    31  * @lib natfwsdpprovider.dll
       
    32  * @since S60 3.2
       
    33  */
       
    34 class TEventReturnStatus
       
    35 	{
       
    36 public: // Enumerations & data
       
    37 
       
    38 	enum TType /* Types of callbacks */
       
    39 		{
       
    40 		ENone,
       
    41 		EInitialized,
       
    42 		EOfferReady,
       
    43 		EAnswerReady,
       
    44 		EUpdateSdp,
       
    45 		EError
       
    46 		} iType;
       
    47 	
       
    48 	TInt iStatus;
       
    49 	CSdpDocument* iOffer;
       
    50 	CSdpDocument* iAnswer;
       
    51 
       
    52 
       
    53 public: // New functions
       
    54 
       
    55 	inline TEventReturnStatus(
       
    56 			TType aType = ENone,
       
    57 			TInt aStatus = KErrNone,
       
    58 			CSdpDocument* aOffer = NULL,
       
    59 			CSdpDocument* aAnswer = NULL )
       
    60 		: iType( aType ),
       
    61 		  iStatus( aStatus ),
       
    62 		  iOffer( aOffer ),
       
    63 		  iAnswer( aAnswer )
       
    64 		{
       
    65 		}
       
    66 	
       
    67 	};
       
    68 
       
    69 
       
    70 /**
       
    71  *  State machine event.
       
    72  *
       
    73  *  Allows incoming event specific data to stored in session level, and handled
       
    74  *  in state machine level.
       
    75  *
       
    76  *  @lib natfwsdpprovider.dll
       
    77  *  @since S60 3.2
       
    78  */
       
    79 class TNSPStateMachineEvent : public TEventReturnStatus
       
    80     {
       
    81 public: // Enumerations
       
    82     
       
    83     enum TRequest /* Types of external events */
       
    84         {
       
    85         ENat,
       
    86         ECreateOffer,
       
    87         EResolve,
       
    88         EDecodeAnswer,
       
    89         EUpdate,
       
    90         EReservationStatus,
       
    91         ECloseSession
       
    92         };
       
    93 
       
    94 
       
    95 public: // New functions
       
    96 
       
    97     inline TNSPStateMachineEvent( TInt aStatus,
       
    98     		CSdpDocument* aOffer,
       
    99             CSdpDocument* aAnswer,
       
   100     		TRequest aRequest,
       
   101             CNSPSession& aSession )
       
   102         : TEventReturnStatus( TEventReturnStatus::ENone, aStatus, aOffer, aAnswer ),
       
   103           iRequest( aRequest ),
       
   104           iSession( aSession ),
       
   105           iNextState( KErrNone )
       
   106         {
       
   107         }
       
   108     
       
   109     inline TEventReturnStatus::TType& CallbackType()
       
   110     	{
       
   111     	return iType;
       
   112     	}
       
   113     
       
   114     inline TInt& Status()
       
   115     	{
       
   116     	return iStatus;
       
   117     	}
       
   118     
       
   119     inline CSdpDocument*& Offer()
       
   120     	{
       
   121     	return iOffer;
       
   122     	}
       
   123     
       
   124     inline CSdpDocument*& Answer()
       
   125     	{
       
   126     	return iAnswer;
       
   127     	}
       
   128     
       
   129     inline TRequest& Request()
       
   130         {
       
   131         return iRequest;
       
   132         }
       
   133     
       
   134     inline CNSPSession& Session()
       
   135         {
       
   136         return iSession;
       
   137         }
       
   138     
       
   139     inline TInt& NextState()
       
   140         {
       
   141         return iNextState;
       
   142         }
       
   143 
       
   144 
       
   145 protected: // data
       
   146 
       
   147     TRequest iRequest;
       
   148     CNSPSession& iSession;
       
   149     TInt iNextState;
       
   150     
       
   151     };
       
   152 
       
   153 
       
   154 
       
   155 /**
       
   156  *  State machine event, for media level specific events.
       
   157  *
       
   158  *  Allows incoming event specific data to stored in session level & media level,
       
   159  *  and handled in state machine level.
       
   160  *
       
   161  *  @lib natfwsdpprovider.dll
       
   162  *  @since S60 3.2
       
   163  */
       
   164 
       
   165 class TNSPStateMachineMediaEvent : public TNSPStateMachineEvent
       
   166 	{
       
   167 public: // New functions
       
   168 
       
   169 	inline TNSPStateMachineMediaEvent( TUint aStreamId,
       
   170 			MNATFWConnectivityObserver::TNATFWConnectivityEvent aEvent,
       
   171 			TAny* aData,
       
   172 			TInt aStatus,
       
   173             CSdpDocument* aOffer,
       
   174             CSdpDocument* aAnswer,
       
   175 			TRequest aRequest,
       
   176             CNSPSession& aSession )
       
   177 		: TNSPStateMachineEvent( aStatus, aOffer, aAnswer, aRequest, aSession ),
       
   178 		  iStreamId( aStreamId ),
       
   179 		  iEvent( aEvent ),
       
   180 		  iData( aData )
       
   181 		{
       
   182 		}
       
   183 	
       
   184 	inline TUint& StreamId()
       
   185 		{
       
   186 		return iStreamId;
       
   187 		}
       
   188 	
       
   189 	inline MNATFWConnectivityObserver::TNATFWConnectivityEvent& Event()
       
   190 		{
       
   191 		return iEvent;
       
   192 		}
       
   193 
       
   194 	inline TAny*& Data()
       
   195 		{
       
   196 		return iData;
       
   197 		}
       
   198 
       
   199 
       
   200 protected: // data
       
   201 
       
   202 	TUint iStreamId;
       
   203 	MNATFWConnectivityObserver::TNATFWConnectivityEvent iEvent;
       
   204 	TAny* iData;
       
   205 	
       
   206 	};
       
   207 
       
   208 
       
   209 #define MEDIAEVENT( aEventRef ) \
       
   210 	static_cast<TNSPStateMachineMediaEvent&> ( aEventRef )
       
   211 
       
   212 
       
   213 #endif // NSPEVENTS_H
       
   214