multimediacommsengine/tsrc/testdriver/siptester/src/TCmdGetConnectionState.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 "CTcSIPConnectionContainer.h"
       
    19 
       
    20 #include "TCmdGetConnectionState.h"
       
    21 #include "SIPConstants.h"
       
    22 
       
    23 // State enumeration names
       
    24 _LIT8( KInit, "init" );
       
    25 _LIT8( KActive, "active" );
       
    26 _LIT8( KSuspended, "suspended" );
       
    27 _LIT8( KInactive, "inactive" );
       
    28 _LIT8( KUnavailable, "unavailable" );
       
    29 
       
    30 /**
       
    31  * INPUT:
       
    32  *   Headers:		-
       
    33  *   Parameters:	-
       
    34  *   IDs:			ConnectionId*
       
    35  *
       
    36  * OUTPUT:
       
    37  *   Parameters:	-
       
    38  *   IDs:			ConnectionState
       
    39  */
       
    40 void TCmdGetConnectionState::ExecuteL()
       
    41 	{
       
    42 	// -- Setup ---------------------------------------------------------------
       
    43 
       
    44 	// Select connection; either default or user specified (and existing)
       
    45 	CSIPConnection& connection = SelectConnectionL().Connection();
       
    46 
       
    47 	// -- Execution -----------------------------------------------------------
       
    48 
       
    49 	// Get connection state
       
    50 	CSIPConnection::TState state = connection.State();
       
    51 
       
    52 	// -- Response creation ---------------------------------------------------
       
    53 
       
    54 	// Map enumeration to text
       
    55 	TPtrC8 stateName;
       
    56 	switch( state )
       
    57 		{
       
    58 		case CSIPConnection::EActive:
       
    59 			{
       
    60 			stateName.Set( KActive );
       
    61 			break;
       
    62 			}
       
    63 		case CSIPConnection::ESuspended:
       
    64 			{
       
    65 			stateName.Set( KSuspended );
       
    66 			break;
       
    67 			}
       
    68 		case CSIPConnection::EInactive:
       
    69 			{
       
    70 			stateName.Set( KInactive );
       
    71 			break;
       
    72 			}
       
    73 		case CSIPConnection::EUnavailable:
       
    74 			{
       
    75 			stateName.Set( KUnavailable );
       
    76 			break;
       
    77 			}
       
    78 		case CSIPConnection::EInit:
       
    79 		default:
       
    80 			{
       
    81 			stateName.Set( KInit );
       
    82 			break;
       
    83 			}
       
    84 		}
       
    85 
       
    86 	AddTextResponseL( KParamConnectionState, stateName );
       
    87 	}
       
    88 
       
    89 TBool TCmdGetConnectionState::Match( const TTcIdentifier& aId )
       
    90 	{
       
    91 	return TTcSIPCommandBase::Match( aId, _L8("GetConnectionState") );
       
    92 	}
       
    93 
       
    94 TTcCommandBase* TCmdGetConnectionState::CreateL( MTcTestContext& aContext )
       
    95 	{
       
    96 	return new( ELeave ) TCmdGetConnectionState( aContext );
       
    97 	}