multimediacommsengine/tsrc/testdriver/siptester/src/TCmdGetDialogState.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 <sipdialog.h>
       
    19 #include <sipdialogassocbase.h>
       
    20 #include <sipinternalstates.h>
       
    21 
       
    22 #include "TCmdGetDialogState.h"
       
    23 #include "SIPConstants.h"
       
    24 
       
    25 // State enumeration names
       
    26 _LIT8( KInit, "init" );
       
    27 _LIT8( KEarly, "early" );
       
    28 _LIT8( KConfirmed, "confirmed" );
       
    29 _LIT8( KTerminated, "terminated" );
       
    30 
       
    31 /**
       
    32  * INPUT:
       
    33  *   Headers:		-
       
    34  *   Parameters:	-
       
    35  *   IDs:			InviteDialogId*, SubscribeDialogId*
       
    36  *
       
    37  * OUTPUT:
       
    38  *   Parameters:	-
       
    39  *   IDs:			DialogState
       
    40  */
       
    41 void TCmdGetDialogState::ExecuteL()
       
    42 	{
       
    43 	// -- Setup ---------------------------------------------------------------
       
    44 
       
    45 	// Get SIP objects from registry
       
    46 	CSIPDialogAssocBase* dialogAssoc = GetAnyDialogAssocL();
       
    47 
       
    48 	// -- Execution -----------------------------------------------------------
       
    49 
       
    50 	// Get dialog state
       
    51 	CSIPInternalStates* internalStates = CSIPInternalStates::NewLC();
       
    52 	CSIPInternalStates::TState state;
       
    53 	User::LeaveIfError( internalStates->GetDialogState(
       
    54 											dialogAssoc->Dialog(), state ) );
       
    55 	CleanupStack::PopAndDestroy( internalStates );
       
    56 
       
    57 	// -- Response creation ---------------------------------------------------
       
    58 
       
    59 	// Map enumeration to text
       
    60 	TPtrC8 stateName;
       
    61 	switch( state )
       
    62 		{
       
    63 		case CSIPInternalStates::EDialogEarly:
       
    64 			{
       
    65 			stateName.Set( KEarly );
       
    66 			break;
       
    67 			}
       
    68 		case CSIPInternalStates::EDialogConfirmed:
       
    69 			{
       
    70 			stateName.Set( KConfirmed );
       
    71 			break;
       
    72 			}
       
    73 		case CSIPInternalStates::EDialogTerminated:
       
    74 			{
       
    75 			stateName.Set( KTerminated );
       
    76 			break;
       
    77 			}
       
    78 		case CSIPInternalStates::EDialogEstablishing:
       
    79 		default:
       
    80 			{
       
    81 			stateName.Set( KInit );
       
    82 			break;
       
    83 			}
       
    84 		}
       
    85 
       
    86 	AddTextResponseL( KParamDialogState, stateName );
       
    87 	}
       
    88 
       
    89 TBool TCmdGetDialogState::Match( const TTcIdentifier& aId )
       
    90 	{
       
    91 	return TTcSIPCommandBase::Match( aId, _L8("GetDialogState") );
       
    92 	}
       
    93 
       
    94 TTcCommandBase* TCmdGetDialogState::CreateL( MTcTestContext& aContext )
       
    95 	{
       
    96 	return new( ELeave ) TCmdGetDialogState( aContext );
       
    97 	}