multimediacommsengine/mmcesrv/mmceserver/src/mcestateclientestablishing.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 "mcestateclientestablishing.h"
       
    23 #include "mcesipsession.h"
       
    24 #include "mceactionset.h"
       
    25 #include "mcefcactionset.h"
       
    26 #include "mceclientserver.h"
       
    27 #include "mcenatmacros.h"
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // CMceStateClientEstablishing::CMceStateClientEstablishing
       
    31 // -----------------------------------------------------------------------------
       
    32 //
       
    33 CMceStateClientEstablishing::CMceStateClientEstablishing ()
       
    34     : CMceState( KMceStateClientEstablishing )
       
    35 	{
       
    36 	}
       
    37 
       
    38 
       
    39 // -----------------------------------------------------------------------------
       
    40 // CMceStateClientEstablishing::~CMceStateClientEstablishing
       
    41 // -----------------------------------------------------------------------------
       
    42 //
       
    43 CMceStateClientEstablishing::~CMceStateClientEstablishing()
       
    44 	{
       
    45 	}
       
    46 
       
    47 
       
    48 // -----------------------------------------------------------------------------
       
    49 // CMceStateClientEstablishing::DoAcceptL
       
    50 // -----------------------------------------------------------------------------
       
    51 //
       
    52 TBool CMceStateClientEstablishing::DoAcceptL( TMceStateTransitionEvent& aEvent )
       
    53 	{
       
    54     //not accepted	
       
    55 	User::LeaveIfError( aEvent.EventSource() == EMceSip ? 
       
    56                         KErrTotalLossOfPrecision :
       
    57                         KErrNone );
       
    58 	
       
    59     User::LeaveIfError(
       
    60       aEvent.Code() == EMceMediaUpdated ||
       
    61       aEvent.Code() == EMceItcCancel ||
       
    62       aEvent.Code() == EMceItcEnable ||
       
    63       aEvent.Code() == EMceItcDisable ||
       
    64       IsExtensionRequestEvent( aEvent )
       
    65       
       
    66         ? KErrNone : KErrTotalLossOfPrecision );
       
    67     
       
    68 	return ETrue;
       
    69 	}
       
    70 
       
    71 // -----------------------------------------------------------------------------
       
    72 // CMceStateClientEstablishing::EntryL
       
    73 // -----------------------------------------------------------------------------
       
    74 //
       
    75 void CMceStateClientEstablishing::EntryL( TMceStateTransitionEvent& aEvent )
       
    76 	{
       
    77 
       
    78 	if ( IsExtensionRequestEvent( aEvent ))
       
    79 		{
       
    80 		HandleExtensionRequestEventL( aEvent );	
       
    81 		}
       
    82 
       
    83 	else
       
    84 		{
       
    85 		CMceSipSession& session = aEvent.Session();
       
    86 	    CMceSipSession::TSubState subState = session.SubState();
       
    87 		
       
    88 	    switch ( aEvent.Code() )
       
    89 	        {
       
    90 	        // media update ready
       
    91 	        case EMceMediaUpdated:
       
    92 	            {
       
    93 	            //send INVITE and  start waiting SIP response
       
    94 	            NAT_WAIT_NO_EXEC( session, session.Actions().EncodeL() );
       
    95 	            
       
    96 		        session.FCActions().UpdateFCOfferL( *session.Offer() );
       
    97 	            session.Actions().SendInviteL();
       
    98 	            break;
       
    99 	            }
       
   100 	        //client has been called cancel, stop media and FC
       
   101 	        //no sending of CANCEL, because INVITE has not been sent yet
       
   102 	        case EMceItcCancel:
       
   103 	            {
       
   104 	            if ( subState == CMceSipSession::EOffering )
       
   105 	                {
       
   106 	                session.Actions().StopMedia();
       
   107 	                session.FCActions().ReleaseFC();
       
   108 	                }
       
   109 	            else if ( subState == CMceSipSession::EUpdating )
       
   110 	                {
       
   111 	                session.Actions().UpdateFailed();
       
   112 	                }
       
   113 	            break;            
       
   114 	            }
       
   115 	        case EMceItcEnable:
       
   116 	        case EMceItcDisable:
       
   117 	            {
       
   118 	            session.Actions().ControlMediaL( aEvent.ParamIDs(), 
       
   119 	                                             (TMceItcFunctions)aEvent.Code() );
       
   120 	            break;
       
   121 	            }  
       
   122 	        default:
       
   123 	            {
       
   124 	            //NOP
       
   125 	            break;
       
   126 	            }
       
   127 	        }
       
   128 		}
       
   129 	}
       
   130 
       
   131 // -----------------------------------------------------------------------------
       
   132 // CMceStateClientEstablishing::ExitL
       
   133 // -----------------------------------------------------------------------------
       
   134 //
       
   135 void CMceStateClientEstablishing::ExitL( TMceStateTransitionEvent& aEvent )
       
   136 	{
       
   137 	
       
   138 	if ( IsExtensionRequestEvent( aEvent ))
       
   139 		{
       
   140 		//Do Nothing;
       
   141 		}
       
   142 	
       
   143 	else 
       
   144 		{
       
   145 		CMceSipSession& session = aEvent.Session();
       
   146 	    CMceSipSession::TSubState subState = session.SubState();
       
   147 		
       
   148 	    switch ( aEvent.Code() )
       
   149 	        {
       
   150 	        case EMceMediaUpdated:
       
   151 	            {
       
   152 	            //if OK, server state -> offering, no client state transition
       
   153 	    	    session.Actions().StateChanged( KMceStateOffering );
       
   154 	    	    break;
       
   155 	            }
       
   156 	        case EMceItcCancel:
       
   157 	            {
       
   158 	            //CANCEL has not been sent -> directly to terminated 
       
   159 	            //state both client and server
       
   160 	            if ( subState == CMceSipSession::EOffering )
       
   161 	                {
       
   162 	                session.Actions().StateChanged( KMceStateTerminated );
       
   163 	                session.Actions().ClientStateChanged( aEvent.ParamIDs(), 
       
   164 	                                                      CMceSession::ETerminated );
       
   165 	                }
       
   166 	            else
       
   167 	                {
       
   168 	                session.Actions().StateChanged( KMceStateEstablished );
       
   169 	                session.Actions().ClientStateChanged( aEvent.ParamIDs(), 
       
   170 	                                                      CMceSession::EEstablished );
       
   171 	                }
       
   172 	            break;
       
   173 	            }
       
   174 	        default:
       
   175 	            {
       
   176 	            //NOP
       
   177 	            break;
       
   178 	            }
       
   179 	        }
       
   180 		}
       
   181 	}
       
   182 
       
   183 
       
   184 
       
   185 // End of File.
       
   186