multimediacommsengine/mmcesrv/mmceserver/src/mcestate.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 #include <sipdialogassocbase.h> 
       
    22 #include <sipdialog.h>
       
    23 #include <sipconnection.h>
       
    24 #include "mcestate.h"
       
    25 #include "mceactionset.h"
       
    26 #include "mcesipsession.h"
       
    27 #include "mcecomsession.h"
       
    28 #include "mcesipconnection.h"
       
    29 #include "mceevents.h"
       
    30 #include "mcesip.h"
       
    31 #include "mcesrvlogs.h"
       
    32 
       
    33 #define MARK_EXIT ETrue
       
    34 
       
    35 // -----------------------------------------------------------------------------
       
    36 // CMceState::CMceState
       
    37 // -----------------------------------------------------------------------------
       
    38 //
       
    39 CMceState::CMceState ( TMceStateIndex aId )
       
    40     : iId( aId )
       
    41 	{
       
    42 	}
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // CMceState::CMceState
       
    46 // -----------------------------------------------------------------------------
       
    47 //
       
    48 TMceStateIndex CMceState::Id ()
       
    49 	{
       
    50 	return iId;
       
    51 	}
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // CMceState::~CMceState
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 CMceState::~CMceState()
       
    58 	{
       
    59 	}
       
    60 
       
    61 // -----------------------------------------------------------------------------
       
    62 // CMceState::AcceptL
       
    63 // -----------------------------------------------------------------------------
       
    64 //
       
    65 TBool CMceState::AcceptL( TMceStateTransitionEvent& aEvent )
       
    66     {
       
    67     TBool ignore = EFalse; 
       
    68     
       
    69     if ( aEvent.Session().SIPConnection().State() == CSIPConnection::EActive )
       
    70         {
       
    71     	if ( aEvent.Code() == EMceProvisionalResponse && 
       
    72     	     MceSip::ResponseCode( aEvent.Session().Response())==KMceSipTrying )
       
    73 	        {
       
    74 	        ignore = ETrue;
       
    75 	        }
       
    76 		else
       
    77 			{
       
    78 			ignore = !DoAcceptL( aEvent );
       
    79 			}
       
    80         }
       
    81     else
       
    82         {
       
    83         User::Leave( KErrNotReady );
       
    84         }
       
    85 
       
    86     return !ignore;
       
    87                     
       
    88     }
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // CMceState::StateEntry
       
    92 // -----------------------------------------------------------------------------
       
    93 //
       
    94 void CMceState::StateEntry( TMceStateTransitionEvent& /*aEvent*/ )
       
    95     {
       
    96     }
       
    97 
       
    98 // -----------------------------------------------------------------------------
       
    99 // CMceState::StateExitL
       
   100 // -----------------------------------------------------------------------------
       
   101 //
       
   102 void CMceState::StateExitL( TMceStateTransitionEvent& aEvent )
       
   103     {
       
   104 	CMceSipSession& session = aEvent.Session();
       
   105     User::LeaveIfNull( &session );
       
   106 	
       
   107     session.CurrentState( MARK_EXIT );
       
   108     
       
   109     }
       
   110 
       
   111 // -----------------------------------------------------------------------------
       
   112 // CMceState::MediaErrorOccured
       
   113 // -----------------------------------------------------------------------------
       
   114 //
       
   115 void CMceState::MediaErrorOccured( TMceStateTransitionEvent& /*aEvent*/ )
       
   116 	{
       
   117 	// NOP
       
   118 	}
       
   119 	
       
   120 
       
   121 
       
   122 
       
   123 // -----------------------------------------------------------------------------
       
   124 // CMceState::IsExtensionRequestEvent
       
   125 // -----------------------------------------------------------------------------
       
   126 //
       
   127 
       
   128 TBool CMceState::IsExtensionRequestEvent( TMceStateTransitionEvent& aEvent ) 
       
   129 	{
       
   130 	MCESRV_DEBUG("CMceState::IsExtensionRequestEvent, Entryt");
       
   131 	TBool extensionRequest = EFalse;
       
   132 	CMceSipSession& session = aEvent.Session();
       
   133 
       
   134 	switch ( aEvent.Code() )
       
   135         {
       
   136         case EMceResponse:
       
   137         case EMceProvisionalResponse:
       
   138         case EMceRedirectionResponse:
       
   139         case EMceErrorResponse:
       
   140             {
       
   141             if ( &session.Response() )
       
   142             	{
       
   143             	RStringF method = session.Response().Type();
       
   144             	extensionRequest = session.Actions().IsExtensionRequest( method );		
       
   145             	}
       
   146             break;
       
   147             }
       
   148             
       
   149         case EMceItcRequestSend:
       
   150         case EMceItcReplySend:
       
   151         case EMceRequest:
       
   152         	{
       
   153         	extensionRequest = ETrue;	
       
   154         	break;	
       
   155         	}
       
   156 
       
   157    		default:
       
   158             {
       
   159             //NO OP
       
   160             break;
       
   161             }
       
   162         }
       
   163 
       
   164     
       
   165 	MCESRV_DEBUG("CMceState::IsExtensionRequestEvent, Exit");	
       
   166 
       
   167 	return extensionRequest;
       
   168 	}
       
   169 
       
   170 
       
   171 // -----------------------------------------------------------------------------
       
   172 // CMceState::HandleExtensionRequestEvent
       
   173 // -----------------------------------------------------------------------------
       
   174 //
       
   175 
       
   176 void CMceState::HandleExtensionRequestEventL( TMceStateTransitionEvent& aEvent )
       
   177 
       
   178 	{
       
   179 	//Handle Non-Target Refresh Request Here
       
   180 	MCESRV_DEBUG("CMceState::HandleExtensionRequestEventL, Entryt");
       
   181 
       
   182 	switch ( aEvent.Code() )
       
   183         {
       
   184         case EMceResponse:
       
   185         case EMceProvisionalResponse:
       
   186         case EMceRedirectionResponse:
       
   187         case EMceErrorResponse:
       
   188             {
       
   189             EntryReceiveExtensionResponseL( aEvent );
       
   190             break;
       
   191             }
       
   192         
       
   193         case EMceItcReplySend:
       
   194         	{
       
   195         	EntrySendExtensionResponseL ( aEvent );
       
   196         	break;	
       
   197         	}
       
   198         	
       
   199         case EMceItcRequestSend:	
       
   200         	{
       
   201         	EntrySendExtensionRequestL ( aEvent );
       
   202         	break;	
       
   203         	}
       
   204        	
       
   205         case EMceRequest:
       
   206         	{
       
   207         	EntryReceiveExtensionRequestL ( aEvent );
       
   208         	break;	
       
   209         	}
       
   210 
       
   211 		default:
       
   212             {
       
   213             break;
       
   214             }        	
       
   215         }
       
   216 		
       
   217 	MCESRV_DEBUG("CMceState::HandleExtensionRequestEvent, Exit");	
       
   218 	}
       
   219 
       
   220 
       
   221 // -----------------------------------------------------------------------------
       
   222 // CMceState::EntrySendExtensionRequestL
       
   223 // -----------------------------------------------------------------------------
       
   224 //
       
   225 void CMceState::EntrySendExtensionRequestL( TMceStateTransitionEvent& aEvent )
       
   226 	{
       
   227 	MCESRV_DEBUG("CMceState::EntrySendExtensionRequestL, Entryt");                           		
       
   228 	CMceSipSession& session = aEvent.Session();
       
   229 
       
   230 	if (( session.Dialog()->Dialog().State() != CSIPDialog::EInit ) &&
       
   231 		( session.Dialog()->Dialog().State() != CSIPDialog::ETerminated )) 
       
   232     
       
   233 		{
       
   234 		session.Actions().SendExtensionRequestL( aEvent.ParamClientMessage(), 
       
   235 											  	aEvent.ParamIDs());
       
   236         }
       
   237     else
       
   238     	{
       
   239     	User::Leave( KErrTotalLossOfPrecision );
       
   240     	}
       
   241   	
       
   242 	MCESRV_DEBUG("CMceState::EntrySendExtensionRequestL, Exit");                           			
       
   243 	}
       
   244 
       
   245 
       
   246 
       
   247 // -----------------------------------------------------------------------------
       
   248 // CMceState::EntrySendExtensionResponseL
       
   249 // -----------------------------------------------------------------------------
       
   250 //
       
   251 void CMceState::EntrySendExtensionResponseL( TMceStateTransitionEvent& aEvent )
       
   252 	{
       
   253 	MCESRV_DEBUG("CMceState::EntrySendExtensionResponseL, Entryt");   
       
   254 	CMceSipSession& session = aEvent.Session();
       
   255 
       
   256 	session.Actions().SendExtensionResponseL( aEvent.ParamClientMessage(),
       
   257 											aEvent.ParamIDs() );
       
   258 						
       
   259 	MCESRV_DEBUG("CMceState::EntrySendExtensionResponseL, Exit");                           			
       
   260 	}
       
   261 
       
   262 
       
   263 
       
   264 // -----------------------------------------------------------------------------
       
   265 // CMceState::EntryReceiveExtensionRequestL
       
   266 // -----------------------------------------------------------------------------
       
   267 //
       
   268 void CMceState::EntryReceiveExtensionRequestL( TMceStateTransitionEvent& aEvent )
       
   269 	{
       
   270 	MCESRV_DEBUG("CMceState::EntryReceiveExtensionRequestL, Entryt");   
       
   271 	CMceSipSession& session = aEvent.Session();
       
   272 
       
   273 	session.Actions().ReceiveExtensionRequestL( aEvent );		
       
   274 
       
   275 	MCESRV_DEBUG("CMceState::EntryReceiveExtensionRequestL, Exit");                           			
       
   276 	
       
   277 	}
       
   278 
       
   279 
       
   280 
       
   281 // -----------------------------------------------------------------------------
       
   282 // CMceState::EntryReceiveExtensionResponseL
       
   283 // -----------------------------------------------------------------------------
       
   284 //
       
   285 void CMceState::EntryReceiveExtensionResponseL( TMceStateTransitionEvent& aEvent )
       
   286 	{
       
   287 	MCESRV_DEBUG("CMceState::EntryReceiveExtensionResponseL, Entryt");                           		
       
   288 	CMceSipSession& session = aEvent.Session();
       
   289 	
       
   290 
       
   291 	if (( session.Dialog()->Dialog().State() != CSIPDialog::EInit ) &&
       
   292 		( session.Dialog()->Dialog().State() != CSIPDialog::ETerminated )) 
       
   293 		
       
   294 		{
       
   295 		session.Actions().ReceiveExtensionResponseL( session.Response(), *session.Body() );
       
   296 		}
       
   297 
       
   298     else
       
   299     	{
       
   300     	User::Leave( KErrTotalLossOfPrecision );
       
   301     	}
       
   302 		  	
       
   303 	MCESRV_DEBUG("CMceState::EntryReceiveExtensionResponseL, Exit");                           			
       
   304 	}
       
   305 	
       
   306 	
       
   307 
       
   308 // End of File
       
   309