multimediacommsengine/mmcesrv/mmceserver/src/mcenatstatecreateoffer.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 #include "mcenatstatecreateoffer.h"
       
    21 #include "mcenatsipsession.h"
       
    22 #include "mceactionset.h"
       
    23 #include "mceclientserver.h"
       
    24 #include "mcenatevents.h"
       
    25 #include "mcesrvlogs.h"
       
    26 
       
    27 // -----------------------------------------------------------------------------
       
    28 // CMceNatStateCreateOffer::CMceNatStateCreateOffer
       
    29 // -----------------------------------------------------------------------------
       
    30 //
       
    31 CMceNatStateCreateOffer::CMceNatStateCreateOffer()
       
    32 	{
       
    33 	}
       
    34 
       
    35 // -----------------------------------------------------------------------------
       
    36 // CMceNatStateCreateOffer::~CMceNatStateCreateOffer
       
    37 // -----------------------------------------------------------------------------
       
    38 //
       
    39 CMceNatStateCreateOffer::~CMceNatStateCreateOffer()
       
    40 	{
       
    41 	}
       
    42 
       
    43 // -----------------------------------------------------------------------------
       
    44 // CMceNatStateCreateOffer::Accept
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 TBool CMceNatStateCreateOffer::Accept( TMceNatStateTransitionEvent& aEvent )
       
    48     {
       
    49     if ( EMceNatOffer == aEvent.NatCode() ||
       
    50          EMceNatError == aEvent.NatCode() ||
       
    51          EMceNatICMPError == aEvent.NatCode())
       
    52         {
       
    53         return ETrue;
       
    54         }
       
    55     else
       
    56         {
       
    57         return EFalse;
       
    58         }
       
    59     }
       
    60 
       
    61 // -----------------------------------------------------------------------------
       
    62 // CMceNatStateCreateOffer::EntryL
       
    63 // -----------------------------------------------------------------------------
       
    64 //
       
    65 void CMceNatStateCreateOffer::EntryL( TMceNatStateTransitionEvent& aEvent )
       
    66 	{
       
    67 	MCESRV_DEBUG( "*** CMceNatStateCreateOffer::EntryL, Entry" );
       
    68         		
       
    69 	aEvent.Session().Actions().EncodeL();
       
    70 	TMceReturnStatus status = aEvent.NatActions().CreateOfferL();
       
    71 	
       
    72 	   
       
    73 	if ( KMceReady == status )
       
    74 	    {
       
    75         aEvent.NatCode() = ( KMceReady == aEvent.ParamStatus() ?
       
    76                 EMceNatSync : aEvent.NatCode() );
       
    77 	    aEvent.NatActions().StateChangedL( aEvent, KMceNatStateWait );
       
    78 	    }
       
    79     else
       
    80         {
       
    81         aEvent.ParamStatus() = status;
       
    82         }
       
    83 	
       
    84 	MCESRV_DEBUG( "*** CMceNatStateCreateOffer::EntryL, Exit" );
       
    85 	}
       
    86 
       
    87 // -----------------------------------------------------------------------------
       
    88 // CMceNatStateCreateOffer::ExitL
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 void CMceNatStateCreateOffer::ExitL( TMceNatStateTransitionEvent& aEvent )
       
    92 	{
       
    93 	MCESRV_DEBUG( "*** CMceNatStateCreateOffer::ExitL, Entry" );
       
    94     
       
    95 	switch ( aEvent.NatCode() )
       
    96 	    {
       
    97 	    case EMceNatError:
       
    98 	    case EMceNatICMPError:
       
    99 	        {
       
   100 	        ExitErrorL( aEvent );
       
   101 	        break;
       
   102 	        }
       
   103 	    default:
       
   104 	        {
       
   105 	        ExitDefaultL( aEvent );
       
   106 	        break;
       
   107 	        }
       
   108 	    }
       
   109     
       
   110 	MCESRV_DEBUG( "*** CMceNatStateCreateOffer::ExitL, Exit" );
       
   111 	}
       
   112 
       
   113 // -----------------------------------------------------------------------------
       
   114 // CMceNatStateCreateOffer::ExitErrorL
       
   115 // -----------------------------------------------------------------------------
       
   116 //
       
   117 void CMceNatStateCreateOffer::ExitErrorL( TMceNatStateTransitionEvent& aEvent )
       
   118     {
       
   119     if ( aEvent.ParamStatus() > KMceNatNonFatalErrorLimit )
       
   120         {
       
   121         aEvent.Session().Actions().ClientErrorOccured( aEvent.ParamStatus() );
       
   122         }
       
   123         
       
   124 	TMceStateIndex sipState = aEvent.Session().CurrentState().Id();
       
   125     
       
   126     if (( aEvent.NatCode() == EMceNatICMPError && 
       
   127     		KMceStateEstablished == sipState ) || 
       
   128     		aEvent.NatCode() == EMceNatError )
       
   129     		
       
   130     	{
       
   131     	aEvent.NatActions().Continue();
       
   132     	User::Leave( aEvent.ParamStatus() );		
       
   133     	}
       
   134        
       
   135     }
       
   136 
       
   137 // -----------------------------------------------------------------------------
       
   138 // CMceNatStateCreateOffer::ExitDefaultL
       
   139 // -----------------------------------------------------------------------------
       
   140 //
       
   141 void CMceNatStateCreateOffer::ExitDefaultL( TMceNatStateTransitionEvent& aEvent )
       
   142     {
       
   143     User::LeaveIfNull( aEvent.Document() );
       
   144     CMceSipSession& session = aEvent.Session();
       
   145     
       
   146     CSdpDocument* previous = session.Offer();
       
   147     aEvent.Session().SetOffer( aEvent.Document() );
       
   148     aEvent.NatActions().SetOffered( KMceNatOfferSdp );
       
   149     aEvent.NatActions().SdpCleanup( previous, session.Offer() );
       
   150     
       
   151     aEvent.NatActions().StateChangedL( aEvent, KMceNatStateWait );
       
   152     }