multimediacommsengine/mmcesrv/mmceserver/src/mcestateserverreserving.cpp
changeset 0 1bce908db942
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 
       
    22 #include "mcestateserverreserving.h"
       
    23 #include "mcesipsession.h"
       
    24 #include "mceactionset.h"
       
    25 #include "mcefcactionset.h"
       
    26 #include "mceclientserver.h"
       
    27 
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // CMceStateServerReserving::CMceStateServerReserving
       
    31 // -----------------------------------------------------------------------------
       
    32 //
       
    33 CMceStateServerReserving::CMceStateServerReserving ()
       
    34     : CMceState( KMceStateServerReserving )
       
    35 	{
       
    36 	}
       
    37 
       
    38 
       
    39 // -----------------------------------------------------------------------------
       
    40 // CMceStateServerReserving::~CMceStateServerReserving
       
    41 // -----------------------------------------------------------------------------
       
    42 //
       
    43 CMceStateServerReserving::~CMceStateServerReserving()
       
    44 	{
       
    45 	}
       
    46 
       
    47 
       
    48 // -----------------------------------------------------------------------------
       
    49 // CMceStateServerReserving::DoAcceptL
       
    50 // -----------------------------------------------------------------------------
       
    51 //
       
    52 TBool CMceStateServerReserving::DoAcceptL( TMceStateTransitionEvent& aEvent )
       
    53 	{
       
    54 	User::LeaveIfError(
       
    55        aEvent.Code() == EMceUpdate ||
       
    56        aEvent.Code() == EMceMediaReserved ||      
       
    57        aEvent.Code() == EMceItcEnable ||
       
    58        aEvent.Code() == EMceItcDisable ||
       
    59        IsExtensionRequestEvent( aEvent )
       
    60        
       
    61        ? KErrNone : KErrTotalLossOfPrecision );
       
    62     
       
    63 	return ETrue;
       
    64 	}
       
    65 
       
    66 // -----------------------------------------------------------------------------
       
    67 // CMceStateServerReserving::EntryL
       
    68 // -----------------------------------------------------------------------------
       
    69 //
       
    70 void CMceStateServerReserving::EntryL( TMceStateTransitionEvent& aEvent )
       
    71 	{
       
    72 
       
    73 	if ( IsExtensionRequestEvent( aEvent ))
       
    74 		{
       
    75 		HandleExtensionRequestEventL( aEvent );	
       
    76 		}
       
    77 		
       
    78 	else
       
    79 		{
       
    80 	    switch ( aEvent.Code() )
       
    81 	        {
       
    82 	        case EMceUpdate:
       
    83 	            {
       
    84 	            EntryUpdateL( aEvent );
       
    85 	            break;
       
    86 	            }
       
    87 	        case EMceMediaReserved:
       
    88 	            {
       
    89 	            EntryMediaReservedL( aEvent );
       
    90 	            break;
       
    91 	            }
       
    92 	        case EMceItcEnable:
       
    93 	        case EMceItcDisable:
       
    94 	            {
       
    95 	            aEvent.Session().Actions().ControlMediaL( aEvent.ParamIDs(), 
       
    96 	                                             (TMceItcFunctions)aEvent.Code() );
       
    97 	            break;
       
    98 	            } 
       
    99 	        default:
       
   100 	            {
       
   101 	            break;
       
   102 	            }
       
   103 	        }
       
   104 		}
       
   105 	}
       
   106 
       
   107 // -----------------------------------------------------------------------------
       
   108 // CMceStateServerReserving::ExitL
       
   109 // -----------------------------------------------------------------------------
       
   110 //
       
   111 void CMceStateServerReserving::ExitL( TMceStateTransitionEvent& aEvent )
       
   112 	{
       
   113 	
       
   114 	if ( IsExtensionRequestEvent( aEvent ))
       
   115 		{
       
   116 		//Do Nothing;
       
   117 		}
       
   118 		
       
   119 	else
       
   120 		{
       
   121 		CMceSipSession& session = aEvent.Session();
       
   122 		TInt status = aEvent.ParamStatus();
       
   123 		switch ( aEvent.Code() )
       
   124 	        {
       
   125 	        case EMceUpdate:
       
   126 	            {
       
   127 	            if ( MCE_IS_ERROR( status ) )
       
   128 	                {
       
   129 	                session.Actions().StateChanged( KMceStateTerminated );
       
   130 	                session.Actions().ClientStateChangedL( CMceSession::ETerminated );
       
   131 	                }
       
   132 	            else if ( status == KMceAsync )
       
   133 	                {
       
   134 	                // go to confirmation required state to wait
       
   135 	                // update to complete. New reservation needed after that.
       
   136 	                session.Actions().StateChanged( 
       
   137 	                    KMceStateConfirmationRequired );
       
   138 	                }
       
   139 	            else // KMceReady
       
   140 	                {
       
   141 	                // NOP
       
   142 	                }
       
   143 	            break;
       
   144 	            }
       
   145 	        case EMceMediaReserved:
       
   146 	            {
       
   147 	            // other state changes are handled in entry
       
   148 	            session.Actions().StateChanged( KMceStateConfirmationRequired );
       
   149 	            break;
       
   150 	            }
       
   151 	        default:
       
   152 	            {
       
   153 	            break;
       
   154 	            }
       
   155 	        }
       
   156 		}
       
   157 	}
       
   158 
       
   159 // -----------------------------------------------------------------------------
       
   160 // CMceStateServerReserving::EntryUpdateL
       
   161 // -----------------------------------------------------------------------------
       
   162 //
       
   163 void CMceStateServerReserving::EntryUpdateL( 
       
   164                                         TMceStateTransitionEvent& aEvent )
       
   165     {
       
   166     CMceSipSession& session = aEvent.Session();
       
   167     TMceSipWarningCode warning = KErrNone;
       
   168     
       
   169     warning = session.Actions().DecodeL();
       
   170     aEvent.ParamStatus() = !warning ? KErrNone : KErrAbort;
       
   171     if ( !warning )
       
   172         {
       
   173         TMceReturnStatus status = session.Actions().UpdateL();
       
   174         aEvent.ParamStatus() = status;
       
   175         }
       
   176             
       
   177     if ( MCE_IS_ERROR( aEvent.ParamStatus() ) )
       
   178         {
       
   179         if ( warning ) //if error, reject offer (4XX out)
       
   180             {
       
   181             session.Actions().SendRejectOfferWithWarningL( warning, session.Request() );
       
   182             }
       
   183         else
       
   184             {
       
   185             MceSip::DiscardRequest( session.Request() );
       
   186             }
       
   187             
       
   188         //reject also invite
       
   189         session.DiscardInvite();
       
   190         }
       
   191     }
       
   192     
       
   193 // -----------------------------------------------------------------------------
       
   194 // CMceStateServerReserving::EntryMediaReservedL
       
   195 // -----------------------------------------------------------------------------
       
   196 //    
       
   197 void CMceStateServerReserving::EntryMediaReservedL( 
       
   198                                         TMceStateTransitionEvent& aEvent )
       
   199     {
       
   200     CMceSipSession& session = aEvent.Session();
       
   201     if ( MCE_NEED_TO_RECEIVE( session ) )
       
   202         {
       
   203         // find out, is the UPDATE received yet
       
   204         CSIPServerTransaction* update = NULL;
       
   205         RStringF trx = session.Request().Type();
       
   206         if ( trx == SIPStrings::StringF( SipStrConsts::EUpdate ) )
       
   207             {
       
   208             update = &session.Request();
       
   209             }
       
   210         
       
   211         if ( update )
       
   212             {
       
   213             session.Actions().EncodeL();
       
   214             session.FCActions().UpdateFCAnswerL( *session.Offer() );
       
   215             session.Actions().SendAnswerL( *update );
       
   216             session.Actions().StateChanged( KMceStateUpdated );
       
   217             session.Actions().ClientStateChangedL( CMceSession::EProceeding,
       
   218                                                    *session.Body(),
       
   219                                                    KErrNone );        
       
   220             }
       
   221         }
       
   222     else
       
   223         {
       
   224         session.Actions().StateChanged( KMceStateUpdated );
       
   225         session.Actions().ClientStateChangedL( CMceSession::EProceeding,
       
   226                                                *session.Body(),
       
   227                                                KErrNone );        
       
   228         }
       
   229     }
       
   230     
       
   231 // End of file