multimediacommsengine/tsrc/testdriver/siptester/src/TCmdGetTransactionState.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2004 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:  Implementation
       
    15 *
       
    16 */
       
    17 
       
    18 #include <sipclienttransaction.h>
       
    19 #include <sipservertransaction.h>
       
    20 #include <sipinternalstates.h>
       
    21 
       
    22 #include "TCmdGetTransactionState.h"
       
    23 #include "SIPConstants.h"
       
    24 
       
    25 // State enumeration names
       
    26 _LIT8( KTrying, "trying" );
       
    27 _LIT8( KCalling, "calling" );
       
    28 _LIT8( KProceeding, "proceeding" );
       
    29 _LIT8( KCompleted, "completed" );
       
    30 _LIT8( KConfirmed, "confirmed" );
       
    31 _LIT8( KTerminated, "terminated" );
       
    32 
       
    33 /**
       
    34  * INPUT:
       
    35  *   Headers:		-
       
    36  *   Parameters:	-
       
    37  *   IDs:			ServerTransactionId, TransactionId
       
    38  *
       
    39  * OUTPUT:
       
    40  *   Parameters:	TransactionState
       
    41  *   IDs:			-
       
    42  */
       
    43 void TCmdGetTransactionState::ExecuteL()
       
    44 	{
       
    45 	// -- Setup ---------------------------------------------------------------
       
    46 
       
    47 	// Get SIP objects from registry
       
    48 	CSIPTransactionBase* transaction = GetClientTransactionL( EFalse );
       
    49 	if( !transaction )
       
    50 		{
       
    51 		transaction = GetServerTransactionL();
       
    52 		}
       
    53 
       
    54 	// -- Execution -----------------------------------------------------------
       
    55 
       
    56 	CSIPInternalStates* internalStates = CSIPInternalStates::NewLC();
       
    57 	CSIPInternalStates::TState state;
       
    58 	User::LeaveIfError( internalStates->GetTransactionState(
       
    59 													*transaction, state ) );
       
    60 	CleanupStack::PopAndDestroy( internalStates );
       
    61 
       
    62 	// -- Response creation ---------------------------------------------------
       
    63 
       
    64 	// Map enumeration to text
       
    65 	TPtrC8 stateName;
       
    66 	switch( state )
       
    67 		{
       
    68 		case CSIPInternalStates::ETransactionTrying:
       
    69 			{
       
    70 			stateName.Set( KTrying );
       
    71 			break;
       
    72 			}
       
    73 		case CSIPInternalStates::ETransactionCalling:
       
    74 			{
       
    75 			stateName.Set( KCalling );
       
    76 			break;
       
    77 			}
       
    78 		case CSIPInternalStates::ETransactionProceeding:
       
    79 			{
       
    80 			stateName.Set( KProceeding );
       
    81 			break;
       
    82 			}
       
    83 		case CSIPInternalStates::ETransactionCompleted:
       
    84 			{
       
    85 			stateName.Set( KCompleted );
       
    86 			break;
       
    87 			}
       
    88 		case CSIPInternalStates::ETransactionConfirmed:
       
    89 			{
       
    90 			stateName.Set( KConfirmed );
       
    91 			break;
       
    92 			}
       
    93 		case CSIPInternalStates::ETransactionTerminated:
       
    94 		default:
       
    95 			{
       
    96 			stateName.Set( KTerminated );
       
    97 			break;
       
    98 			}
       
    99 		}
       
   100 
       
   101 	AddTextResponseL( KParamTransactionState, stateName );
       
   102 	}
       
   103 
       
   104 TBool TCmdGetTransactionState::Match( const TTcIdentifier& aId )
       
   105 	{
       
   106 	return TTcSIPCommandBase::Match( aId, _L8("GetTransactionState") );
       
   107 	}
       
   108 
       
   109 TTcCommandBase* TCmdGetTransactionState::CreateL( MTcTestContext& aContext )
       
   110 	{
       
   111 	return new( ELeave ) TCmdGetTransactionState( aContext );
       
   112 	}
       
   113