multimediacommsengine/mmcesrv/mmceserver/inc/mcesipsession.h
changeset 0 1bce908db942
child 3 513a8b745b2f
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2005 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:   
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef CMCESIPSESSION_H
       
    22 #define CMCESIPSESSION_H
       
    23 
       
    24 // INCLUDES
       
    25 #include <e32base.h>
       
    26 
       
    27 #include "mcesrv.h"
       
    28 #include "mcecssubsession.h"
       
    29 #include "mcesipmanager.h"
       
    30 #include "mcestate.h"
       
    31 #include "fcobserver.h"
       
    32 #include "mceexpirationhandler.h"
       
    33 #include "mcereliableobserver.h"
       
    34 
       
    35 // FORWARD DECLARATION
       
    36 class CSIPProfile;
       
    37 class CMceSipStateMachine;
       
    38 class CMceComSession;
       
    39 class TMceActionSet;
       
    40 class TMceFCActionSet;
       
    41 class CMceSipExtensions;
       
    42 class CDesC8Array;
       
    43 class CMceReliableSender;
       
    44 
       
    45 // CLASS DECLARATION
       
    46 
       
    47 
       
    48 /**
       
    49 * This class represents SIP session
       
    50 * 
       
    51 * Class provides methods to handle SIP session
       
    52 * specifig ITC functions and to receive SIP requests and 
       
    53 * responses.
       
    54 
       
    55 *  @lib 
       
    56 *  @since
       
    57 */
       
    58 class CMceSipSession : public CMceCsSubSession,
       
    59 					   public MMceMediaSessionObserver,
       
    60                        public MMCEExpirationHandler,
       
    61                        public MFCObserver,
       
    62                        public MMceReliableObserver
       
    63 	{
       
    64 	
       
    65 public: //enums
       
    66 
       
    67     enum TSubState
       
    68         {
       
    69         ENone,
       
    70         EOffering,
       
    71         EAnswering,
       
    72         EUpdating,
       
    73         ERefreshing,
       
    74         };
       
    75 
       
    76 public: // Constructors and destructor
       
    77 
       
    78 	/**
       
    79 	* Two-phased constructor.
       
    80 	* @param aClientSession client
       
    81 	* @param aSIPConnection SIP connection 
       
    82 	* @param aStateMachine SIP session state machine
       
    83 	* @param aProfile SIP Profile
       
    84 	* @return SIP session
       
    85 	*/
       
    86 	static CMceSipSession* NewL( CMceCsSession& aClientSession, 
       
    87 	                             CMceSipConnection& aSIPConnection,
       
    88 								 CMceSipStateMachine& aStateMachine, 
       
    89 								 CSIPProfile& aProfile );
       
    90 
       
    91 	/**
       
    92 	* Two-phased constructor.
       
    93 	* @param aClientSession client
       
    94 	* @param aSIPConnection SIP connection 
       
    95 	* @param aStateMachine SIP session state machine
       
    96 	* @param aProfile SIP Profile
       
    97 	* @return SIP session
       
    98 	*/
       
    99 	static CMceSipSession* NewLC( CMceCsSession& aClientSession, 
       
   100 	                              CMceSipConnection& aSIPConnection,
       
   101 								  CMceSipStateMachine& aStateMachine, 
       
   102 								  CSIPProfile& aProfile );
       
   103 
       
   104 	/**
       
   105 	* Two-phased constructor.
       
   106 	* @param aClientSession client
       
   107 	* @param aSIPConnection SIP connection 
       
   108 	* @param aStateMachine SIP session state machine
       
   109 	* @return SIP session
       
   110 	*/
       
   111 	static CMceSipSession* NewLC( CMceCsSession& aClientSession, 
       
   112 	                              CMceSipConnection& aSIPConnection,
       
   113 								  CMceSipStateMachine& aStateMachine ); 
       
   114 	
       
   115 	/**
       
   116 	* Destructor.
       
   117 	*/
       
   118 	~CMceSipSession();
       
   119 
       
   120 public: // New
       
   121 
       
   122 	/**
       
   123 	* Returns actions set
       
   124 	* @return action set
       
   125 	*/
       
   126     TMceActionSet Actions();
       
   127     
       
   128     /**
       
   129 	* Returns floor control actions set
       
   130 	* @return floor control action set
       
   131 	*/
       
   132     TMceFCActionSet FCActions();
       
   133     
       
   134 	/**
       
   135 	* Sets substate of session
       
   136 	* @param aSubState substate of session
       
   137 	*/
       
   138     void SetSubState( TSubState aSubState );
       
   139     
       
   140 	/**
       
   141 	* Returns substate of session
       
   142 	* @return substate of session
       
   143 	*/
       
   144     TSubState SubState();
       
   145  
       
   146     /**
       
   147     * Returns Reliable Sender 
       
   148     * @return Reliable Sender
       
   149     */
       
   150 	CMceReliableSender& ReliableSender();
       
   151 		
       
   152 	/**
       
   153     * Re-Create an outgoing dialog 
       
   154     */
       
   155 	void ReCreateOutgoingDialogL();
       
   156 	
       
   157 	/**
       
   158 	* Create outgoing dialog from 3xx response
       
   159 	*/ 
       
   160 	void CreateDialogFrom3XXResponseL();
       
   161 	
       
   162 	/** 
       
   163 	* Re-Use dialog
       
   164 	* @return KErrNone if it passes
       
   165 	*/
       
   166 	
       
   167 	TInt ReUseDialog();
       
   168 	
       
   169 	/** 
       
   170 	* Returns Status for ForcedSDPSending Flag. 
       
   171 	* @return ETrue when resource reservation ongoing otherwise EFalse
       
   172 	*/
       
   173 	
       
   174 	TBool ForceSDPSendingStatus();
       
   175 	
       
   176 	/** 
       
   177 	* Returns the previous state of sip session
       
   178 	* @return StateInded
       
   179 	*/
       
   180 	
       
   181 	TMceStateIndex PreviousState();	
       
   182    
       
   183 public: // from CMceCsSubSession
       
   184 
       
   185 	/**
       
   186 	* Executes ITC function called by client.
       
   187 	* @param aIds set of ids defining ITC call context
       
   188 	* @param aFunction ITC function to be executed
       
   189 	* @return aReturnMessage buffer to store message context,
       
   190 	* which will be wrote back to client
       
   191 	*/
       
   192     HBufC8* DoServiceL( TMceIds& aIds, 
       
   193                         TMceItcFunctions aFunction );
       
   194 
       
   195 	/**
       
   196 	* Executes ITC function called by client.
       
   197 	* @param aIds set of ids defining ITC call context
       
   198 	* @param aFunction ITC function to be executed
       
   199 	* @param aMessage message context from client
       
   200 	*/
       
   201     void DoServiceL( TMceIds& aIds, 
       
   202                      TMceItcFunctions aFunction, 
       
   203      	             const TDesC8& aMessage );
       
   204 
       
   205 	/**
       
   206 	* Executes ITC function called by client.
       
   207 	* @param aIds set of ids defining ITC call context
       
   208 	* @param aFunction ITC function to be executed
       
   209 	* @param aMessage message context from client
       
   210 	*/
       
   211     void DoServiceL( TMceIds& aIds, 
       
   212                      TMceItcFunctions aFunction, 
       
   213      	             TPtr8& aMessage );
       
   214 
       
   215 
       
   216 	/**
       
   217 	* Executes ITC function called by client.
       
   218 	* @param aIds set of ids defining ITC call context
       
   219 	* @param aFunction ITC function to be executed
       
   220 	* @param aMessage decoded message context from client
       
   221 	*/
       
   222     void DoServiceL( TMceIds& aIds, 
       
   223                      TMceItcFunctions aFunction, 
       
   224      	             CMceMsgBase& aMessage );
       
   225 			 
       
   226 	/**
       
   227 	* Returns ETrue, if session can be deleted
       
   228 	* @return ETrue, if session can be deleted
       
   229 	*/
       
   230     TBool CanDispose();
       
   231 	
       
   232 	/**
       
   233 	* Initializes incoming dialog
       
   234 	* @param aTransaction server transaction representing a request,
       
   235 	* which caused dialog creation
       
   236 	*/
       
   237     void DoInitializeIncomingDialogL( CSIPServerTransaction& aTransaction );
       
   238 			 
       
   239     /**
       
   240     * Called when error has been occured within dialog
       
   241     * @param aError error code
       
   242     */
       
   243     void ErrorOccured( TInt aError );
       
   244     
       
   245     /**
       
   246 	* Handles situation where an asynchronous error has occured 
       
   247 	* related to a request within an existing dialog.
       
   248     *
       
   249     * @param aError error code
       
   250     * @param aTransaction the transaction
       
   251     */
       
   252     void DoErrorOccured( TInt aError, CSIPTransactionBase& aTransaction );
       
   253      
       
   254     
       
   255     /**
       
   256 	* Handles situation where SIP connection state has changed.
       
   257     * If connection state has changed to EInactive or EUnavailable,
       
   258 	* SIP stack terminates all pending SIP client transactions and no
       
   259     * errors are reported back to the client about the terminated
       
   260     * transactions.
       
   261 	* @param aIsActive indicates if the current connection is active
       
   262     */
       
   263     void DoConnectionStateChanged( TBool aIsActive );
       
   264 
       
   265     /**
       
   266     * Handles situation where incoming INVITE was 
       
   267     * canceled with the CANCEL
       
   268     */
       
   269     void Canceled();
       
   270     
       
   271     /**
       
   272     * Creates new incoming dialog (association)
       
   273     * @param aInitialRequest request causing creation
       
   274     * @return created dialog association
       
   275     */
       
   276     CSIPDialogAssocBase* CreateIncomingDialogL( 
       
   277                                     CSIPServerTransaction& aInitialRequest );
       
   278 
       
   279     /**
       
   280     * Creates outgoing dialog (association) based on given parameters 
       
   281     * @param aDialogType type of new dialog
       
   282     * @param aParams parameters for creation
       
   283     * @return created dialog association
       
   284     */
       
   285     CSIPDialogAssocBase* CreateOutgoingDialogL( TMceDialogType aDialogType, 
       
   286                                                 CDesC8Array& aParams,
       
   287                                                 CSIPDialog& aExistingDialog );
       
   288 
       
   289     /**
       
   290     * Creates outgoing dialog (association) based on given parameters 
       
   291     * @param aDialogType type of new dialog
       
   292     * @param aParams parameters for creation
       
   293     * @return created dialog association
       
   294     */
       
   295     CSIPDialogAssocBase* CreateOutgoingDialogL( TMceDialogType aDialogType,
       
   296                                                 CDesC8Array& aParams );
       
   297        
       
   298 
       
   299 public: //CMceCsSubSession
       
   300 
       
   301 	/**
       
   302 	* Returns SIP dialog (assoc)
       
   303 	* @return SIP dialog or NULL if it does not exist
       
   304 	*/
       
   305     CSIPDialogAssocBase* Dialog() const;
       
   306 
       
   307     /**
       
   308     * Handles situation where SIP stack has completed UAC core INVITE 
       
   309     * transaction 64*T1 seconds after the reception of the first 
       
   310     * 2xx response. No more 2xx responses can be received to the issued 
       
   311     * single INVITE.
       
   312     * @param aTransaction client transaction representing a response
       
   313     */
       
   314     void InviteCompleted( CSIPClientTransaction& aTransaction );
       
   315     
       
   316    	/**
       
   317 	* Returns ETrue, if session will consume the transaction
       
   318 	* @param aDialog SIP dialog
       
   319 	* @param aTransaction the pending transaction
       
   320 	* @return ETrue, if session will consume the transaction
       
   321 	*/
       
   322 
       
   323     TBool Consumes( CSIPDialog& aDialog, CSIPServerTransaction& aTransaction, 
       
   324                 	 TBool& aAssociatesWithDialog );
       
   325                 	 
       
   326 
       
   327 protected: //CMceCsSubSession
       
   328 
       
   329 
       
   330     /**
       
   331     * Checks if session accepts method of incoming request
       
   332     * @param aMethod the method
       
   333     * @return ETrue, if session will accept
       
   334     */
       
   335     TBool AcceptMethod( RStringF aMethod );
       
   336 
       
   337     /**
       
   338     * Called when request has been received. 
       
   339     * Request can be obtained by calling Request() method
       
   340     * @param aInsideDialog tells whether request was received inside dialog
       
   341     * @param aDialog SIP Dialog to which request belongs
       
   342     */
       
   343     void RequestReceived( TBool aInsideDialog, CSIPDialog& aDialog  );
       
   344     
       
   345         
       
   346     /**
       
   347     * Called when response (2XX) has been received to pending transaction.
       
   348     * Response can be obtained by calling Response() method
       
   349     */
       
   350     void ResponseReceived();
       
   351     
       
   352     /**
       
   353     * Called when response (1XX) has been received to pending transaction.
       
   354     * Response can be obtained by calling Response() method
       
   355     */
       
   356     void ProvisionalResponseReceived();
       
   357     
       
   358     /**
       
   359     * Called when response (3XX) has been received to pending transaction.
       
   360     * Response can be obtained by calling Response() method
       
   361     */
       
   362     void RedirectionResponseReceived();
       
   363      
       
   364     /**
       
   365     * Called when error response (4XX-7XX) has been received 
       
   366     * to pending transaction. 
       
   367     * Response can be obtained by calling Response() method
       
   368     */
       
   369     void ErrorResponseReceived();
       
   370     
       
   371     /**
       
   372     * Called when stand-alone request has been received.
       
   373     * Request can be obtained by calling Request() method
       
   374     */
       
   375     void StandAloneRequestReceived();
       
   376     
       
   377     /**
       
   378     * Called when stand-alone response (any) has been received 
       
   379     * to pending transaction. 
       
   380     * Response can be obtained by calling Response() method
       
   381     * @param aResponseType response type
       
   382     */
       
   383     void StandAloneResponseReceived( TMceSipResponseType aResponseType );
       
   384 
       
   385     /**
       
   386     * Handles situation where session must be forcefully terminated
       
   387     * @return ETrue, if session can be deleted. If there are 
       
   388     * pending operations, which cannot be done within this call, EFalse
       
   389     * is returned.
       
   390     */
       
   391     TBool Terminate();
       
   392     
       
   393     
       
   394 public: // from MMceMediaSessionObserver
       
   395 
       
   396     /**
       
   397     * Callback function to indicate MCC session
       
   398     * is updated.
       
   399     * @param aSession session body
       
   400     */
       
   401     virtual void Updated( CMceComSession& aSession );
       
   402 
       
   403     /**
       
   404     * Callback function to indicate that network 
       
   405     * resource reservation is now ready
       
   406     */
       
   407     void Reserved( CMceComSession& aSession );
       
   408 
       
   409     /**
       
   410     * Callback function to indicate that event has been received
       
   411     * @param aEvent, received event
       
   412     */
       
   413     void EventReceived( TMceMccComEvent& aEvent );
       
   414 
       
   415 	/**
       
   416     * Callback function to indicate MCC session was stopped
       
   417     * @param aSession session body
       
   418     */
       
   419 	void SessionClosed( CMceComSession& aSession );
       
   420 	
       
   421     /**
       
   422     * Callback function to indicate about error
       
   423     * @param aEvent, received event
       
   424     */
       
   425     void MediaError( TMceMccComEvent& aEvent );
       
   426     
       
   427     /**
       
   428     * Callback function to indicate about new media session due fork
       
   429     * @param aSession, new session, onwership is been transfered
       
   430     */
       
   431     void SessionCreatedL ( CMceComSession* aSession );
       
   432 
       
   433 	
       
   434 public: // From MMCEExpirationHandler	
       
   435 
       
   436 	/**
       
   437     * Callback function to indicate about expiration of
       
   438     * session timer. RFC 4028
       
   439     * @param aTimerId timer Id
       
   440     * @param aTimerParam timer param
       
   441     */
       
   442     void TimerExpiredL( TMceTimerId aTimerId, TAny* aTimerParam );
       
   443 
       
   444 
       
   445 public: // From MFCObserver
       
   446 	    
       
   447     /**
       
   448 	* A FC message has been received from the network.        
       
   449     * @param aData The Data received from FCsession specific plugIn 
       
   450     *        The ownership is transferred.
       
   451 	* @param aFCSession The Session which data is received to.
       
   452     */
       
   453 	void FCReceivedData( HBufC8* aData, const CFCSession* aFCSession );
       
   454 
       
   455 	/**
       
   456 	* An asynchronous error has occurred in the FC related to the
       
   457 	* given session indicated.
       
   458 	* @param aError KErrNone succesfully, otherwise system wide or Socket 
       
   459 	*               error code
       
   460 	* @param aFCSession The Session which error is received to.
       
   461 	*/
       
   462 	void FCErrorNotify( TInt aErrCode, const CFCSession* aFCSession );
       
   463 
       
   464 
       
   465 
       
   466 public: // From MCEReliableObserver
       
   467     
       
   468     /**
       
   469     * Callback Function, this will be called when reliable sender, retransmission 
       
   470     * timer expires, i.e. reliable sender has sent transaction for 64T1 and has not 
       
   471     * got the corresponding PRACK.
       
   472     * 
       
   473     */
       
   474     void NoPrackReceived( CSIPServerTransaction& aTransaction );
       
   475     
       
   476     
       
   477     /**
       
   478     * Callback Function indicates reliable sender has failed. This may be called 
       
   479     * when a transaction is in progress and UA tries to send another reliable response.
       
   480     */
       
   481     void ReliableFailed( CSIPServerTransaction& aTransaction, TInt aError );
       
   482     
       
   483     
       
   484 public: //New Functions
       
   485 
       
   486 
       
   487 	
       
   488 	/**
       
   489     * Returns pending invite transaction
       
   490     * @return pending invite transaction
       
   491     */
       
   492     CSIPClientTransaction* InviteTransaction();
       
   493     
       
   494 	/**
       
   495     * Returns current state
       
   496     * @param aMarkExit indicates, if current state is marked as exit state
       
   497     * @return current state
       
   498     */
       
   499     CMceState& CurrentState( TBool aMarkExit = EFalse );
       
   500 
       
   501 	/**
       
   502     * Create body
       
   503     * @param aSession
       
   504     */
       
   505     void CMceSipSession::SetBodyL( CMceComSession* aSession = NULL );
       
   506     
       
   507 	/**
       
   508     * Returns session body
       
   509     * @return session body
       
   510     */
       
   511     CMceComSession* Body();
       
   512     
       
   513 	/**
       
   514     * Returns session body candidate
       
   515     * @return session body candidate
       
   516     */
       
   517     CMceComSession* BodyCandidate();
       
   518 
       
   519 	/**
       
   520     * Returns active session body 
       
   521     * @return active session body 
       
   522     */
       
   523     CMceComSession& ActiveBody();
       
   524     
       
   525     /**
       
   526     * Sets the latest offer
       
   527     * @param aSdpDocument the latest offer
       
   528     */
       
   529     virtual void SetOffer( CSdpDocument* aSdpDocument );
       
   530     
       
   531 	/**
       
   532     * Returns last offer (or answer) issued to session
       
   533     * @return last offer (or answer) issued to session
       
   534     */
       
   535     virtual CSdpDocument* Offer();
       
   536 
       
   537 	/**
       
   538     * Sets the previous offer
       
   539     * @param aSdpDocument the latest offer
       
   540     */
       
   541     virtual void SetPrevOffer( CSdpDocument* aSdpDocument );
       
   542     
       
   543     /**
       
   544     * Returns one before last offer (or answer) issued to session
       
   545     * @return one before last offer (or answer) issued to session
       
   546     */
       
   547     virtual CSdpDocument* PrevOffer();
       
   548     
       
   549     /**
       
   550     * Sets the latest offer
       
   551     * @param aSdpDocument the latest offer
       
   552     */
       
   553     virtual void StorePrevOffer();
       
   554     
       
   555     /**
       
   556     * Method used to check if sip session is a Nat sip sesssion.
       
   557     * @return ETrue is Sip session is a Nat sip session, EFalse otherwise.
       
   558     */
       
   559     virtual TBool NatSession() const;
       
   560     
       
   561 	/**
       
   562     * Returns Nat sip session sub state.
       
   563     * @return Enumeration depicting session's Nat substate.
       
   564     */
       
   565     virtual TInt NatState() const;
       
   566     
       
   567     /**
       
   568     * Check if the NAT has been disabled.
       
   569     * @return ETrue NAT is disabled, EFalse otherwise
       
   570     */
       
   571     virtual TBool IsNatDisabled() const;
       
   572     
       
   573     /**
       
   574     * Updates media
       
   575     * @return return status:
       
   576     *       -System error < 0: error situation
       
   577     *       -KMceReady: update was synchronous
       
   578     *       -KMceAsync: updating asynchronously
       
   579     */
       
   580     virtual TMceReturnStatus UpdateMediaL();
       
   581     
       
   582 	/**
       
   583     * Resource Reservation Status 
       
   584     * @return return status TMceReturnStatus
       
   585     *       -KMceReady: resrouces reserved
       
   586     *       -KMceAsync: resource reservation asynchronously
       
   587     */
       
   588     
       
   589 	virtual TMceReturnStatus ReserveL();
       
   590 	
       
   591     /**
       
   592     * Tells whether SDP to be sent to network.
       
   593     * @param aSdpDocument, un-decoded received offer, 
       
   594     *        to check if it is session refresh.
       
   595     * @return ETrue, if SDP needs to be sent
       
   596     */    
       
   597     TBool NeedToSend( CSdpDocument* aSdpDocument );
       
   598     
       
   599     /**
       
   600     * Returns whether a SDP is expected to be received
       
   601     * @return ETrue, if expected to receive SDP
       
   602     */    
       
   603     TBool NeedToReceive();
       
   604     
       
   605 	/**
       
   606     * Sets next state
       
   607     * @param aNextStateId next state id
       
   608     */
       
   609     void NextState( TUint aNextStateId );
       
   610     
       
   611     /**
       
   612     * Starts the session timer
       
   613     */
       
   614     void StartSessionTimerL();
       
   615     
       
   616     /**
       
   617     * Starts the pending timer
       
   618     * @param aInterval interval in milli seconds
       
   619     */
       
   620     void StartPendingTimerL( TUint aInterval );
       
   621     
       
   622     /**
       
   623     * Causes pending update to be accepted
       
   624     */
       
   625     void UpdateAccepted();
       
   626     
       
   627     /**
       
   628     * Causes pending update to be rejected
       
   629     */
       
   630     void UpdateRejected();
       
   631     
       
   632     /**
       
   633     * Prepares ITC callback context
       
   634     * @param aIds set of ids defining ITC callback context
       
   635     */
       
   636     void PrepareIdsL( TMceIds& aIds ) const;
       
   637 
       
   638     /**
       
   639     * Returns truth value, is FC in use or not.
       
   640     * Set to ETrue, when initializing FC for MO sessions and
       
   641     * when updating FC for MT sessions.
       
   642     * @return ETrue, if FC is in use.
       
   643     */
       
   644     TBool UseFC();
       
   645     
       
   646     /**
       
   647     * Invite has been received multiple replies and thus stack
       
   648     * has creted new dialog for others 
       
   649     * @param aTransaction The original invite transaction.
       
   650     * @param aDialogAssoc new dialog
       
   651     */
       
   652     void InviteForkedL( CSIPClientTransaction& aTransaction,
       
   653           		        CSIPInviteDialogAssoc* aDialogAssoc );
       
   654     
       
   655     /**
       
   656     * Returns as a boolean value whether the session is
       
   657     * waiting for a media callback
       
   658     * @return ETrue, if waiting for Media Manager callback
       
   659     */
       
   660     TBool WaitingMediaCallback() const;
       
   661     
       
   662     /**
       
   663     * Sets the boolean value whether the session is
       
   664     * waiting for a media callback
       
   665     * @param aWaiting the value to be set
       
   666     */
       
   667     void SetWaitingMediaCallback( TBool aWaiting );
       
   668     
       
   669     /**
       
   670     * Returns the media authorization token. Ownership is not transfered.
       
   671     */
       
   672     HBufC8* MediaAuthorizationToken() const;
       
   673     
       
   674     /**
       
   675     * Sets the media authorization token. Ownership is transfered.
       
   676     * aToken the media authorization token
       
   677     */
       
   678     void SetMediaAuthorizationToken( HBufC8* aToken );
       
   679     
       
   680     /**
       
   681     * Returns the SIP extensions.
       
   682     * @return the extensions
       
   683     */
       
   684     CMceSipExtensions& Extensions();
       
   685        
       
   686     /**
       
   687     * Sets the RSeq Value.
       
   688     * aRSeq RSeq Value
       
   689     */
       
   690     void SetRSeq( TUint aRSeq );
       
   691     
       
   692     /**
       
   693     * Gets the RSeq Value
       
   694     * @return int RSeq Value.
       
   695     */
       
   696     TInt RSeq();
       
   697     
       
   698     /**
       
   699     * Discards invite
       
   700     */
       
   701     void DiscardInvite();
       
   702 
       
   703     void CloseMedia( TBool aDelete = EFalse );
       
   704     void CloseBodyBucket();
       
   705     
       
   706     /**
       
   707     * Add the URIs in the Contact headers of aResponseElements
       
   708     */
       
   709     void AddRemoteUriFromResponseL( CSIPResponseElements& aResponseElements );
       
   710 
       
   711     /**
       
   712     * Change currently used sdp 
       
   713     */
       
   714     void SdpCleanup( CSdpDocument* aPrevious, CSdpDocument* aReplacement );
       
   715 
       
   716     void ServerInitializedL();
       
   717 
       
   718     void ContinueHandlingIncomingSessionL();
       
   719     
       
   720     void IncrementSentSdpCount();
       
   721     
       
   722     void IncrementReceivedSdpCount();
       
   723     
       
   724     void ResetSdpCounts();
       
   725 
       
   726     TBool DoesMediaManagerNeedToNegotiate( CSdpDocument* aSdpDocument );
       
   727     
       
   728     TBool IsNatSession();
       
   729 
       
   730     TInt ForkedDialogsCount();
       
   731 	
       
   732 protected:
       
   733 
       
   734 
       
   735 	CMceSipSession ( CMceCsSession& aClientSession, 
       
   736 	                 CMceSipConnection& aSIPConnection,
       
   737 					 CMceSipStateMachine& aStateMachine,
       
   738 					 CSIPProfile& aProfile );
       
   739 					 
       
   740 	CMceSipSession ( CMceCsSession& aClientSession, 
       
   741 	                 CMceSipConnection& aSIPConnection,
       
   742 					 CMceSipStateMachine& aStateMachine );
       
   743 					 
       
   744 	void ConstructL( CMceCsSession& aClientSession );
       
   745     
       
   746     virtual void HandleSIPEvent( TMceSipEventCode aEventCode, CSIPDialog& aDialog );
       
   747     
       
   748     void HandleSIPEventErrorL( TMceSipEventCode aEventCode, TInt aError );
       
   749     
       
   750     void PrevOfferSafeDelete();
       
   751     
       
   752     
       
   753 private:
       
   754 
       
   755 
       
   756     TMceSipEventCode MethodCode( RStringF method );
       
   757     
       
   758     void LocalErrorOccured( TMceStateIndex aNewState, TInt aWithError );
       
   759     
       
   760     void HandleForkedDialogs();
       
   761         
       
   762 	CSIPInviteDialogAssoc* DoCreateOutgoingDialogL( CUri8* remoteURI, 
       
   763                                                   CSIPToHeader* to=0 );
       
   764     void DoTerminateL();
       
   765     
       
   766     void DoAutoEventL( TMceStateTransitionEvent& aEvent );
       
   767     
       
   768     /*
       
   769     * Add remote uri from invite request
       
   770     */
       
   771     void AddRemoteUriL( const CUri8& aRemoteUri );
       
   772     
       
   773     /*
       
   774     * return KErrNotFound if not found, otherwise the index of
       
   775     * the found uri in remoteUri Array.
       
   776     */
       
   777     TInt FindRemoteUri( const CUri8& aRemoteUri );
       
   778     
       
   779     void ClearRemoteUri( const TMceStateIndex aState );
       
   780     
       
   781     /**
       
   782     * Returns dialog confirmation status
       
   783     * @return ETrue if dialog is confirmed, EFalse otherwise
       
   784     */
       
   785     TBool IsSipDialogConfirmed() const;
       
   786 
       
   787 protected: // Own Data
       
   788 
       
   789     //SDP offer/answer
       
   790     CSdpDocument* iOffer;
       
   791     
       
   792     // Force SDP Sending Flag used for Resrouce Reservation
       
   793     TBool iForceSDPSending;
       
   794             
       
   795     // Previous Offer/Answer document, own.
       
   796     CSdpDocument* iPrevOffer;
       
   797     
       
   798     //Flag indicating session type
       
   799     TBool iNatSession;
       
   800               
       
   801 private: // NOT own Data
       
   802 
       
   803     //SIP session FSM
       
   804     CMceSipStateMachine* iStateMachine;
       
   805     CMceReliableSender * iReliableSender;
       
   806 
       
   807 private: // Own Data
       
   808 
       
   809     //session body
       
   810     CMceComSession* iBody;
       
   811     //session body candidate
       
   812     CMceComSession* iNewBodyCandidate;
       
   813     //current state of session
       
   814     CMceState* iCurrentState;
       
   815     //state from which FSM has exited
       
   816     CMceState* iExitState;
       
   817     //previous state
       
   818     TUint iPreviousState;
       
   819     //session timer
       
   820     TMceTimerId iTimer;
       
   821     //sub-state of session
       
   822     TSubState iSubState;
       
   823     //is FC in use or not
       
   824     TBool iUseFC;
       
   825     // pending timer
       
   826     TMceTimerId iPendingTimer;
       
   827     // forked dialogs
       
   828     RPointerArray<CSIPInviteDialogAssoc> iForkedDialogs;
       
   829     // is the session waiting for a Media Manager callback
       
   830     TBool iWaitingMediaCallback;
       
   831     // media authorization token
       
   832     HBufC8* iMediaAuthorizationToken;
       
   833     // SIP extensions
       
   834     CMceSipExtensions* iExtensions;
       
   835     // RSeq Value from the Response
       
   836     TUint iRSeq; 
       
   837     
       
   838     RPointerArray<CUri8> iRemoteUri;
       
   839     RPointerArray<CMceComSession> iBodyBucket;
       
   840     
       
   841     TInt iSentSdpCount;
       
   842     TInt iReceivedSdpCount;
       
   843     
       
   844     friend class TMceActionSet;
       
   845     friend class TMceFCActionSet;
       
   846     
       
   847 	//definitions for unit testing
       
   848 	MCESRV_UT_DEFINITIONS        
       
   849 	};
       
   850 
       
   851 #endif
       
   852 
       
   853 // End of File