multimediacommsengine/tsrc/MMCTestDriver/MCETester/src/TCmdSendResponse.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2008 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 
       
    19 
       
    20 #include "MCEConstants.h"
       
    21 #include "TCmdSendResponse.h"
       
    22 #include "CTcMCEContext.h"
       
    23 #include "mcesession.h"
       
    24 
       
    25 // -----------------------------------------------------------------------------
       
    26 // TCmdSendResponse::ExecuteL
       
    27 // -----------------------------------------------------------------------------
       
    28 //
       
    29 void TCmdSendResponse::ExecuteL()
       
    30 	{
       
    31 
       
    32 	// ---------- Setup --------------------------------------------------------
       
    33 	const TBool KOptional = EFalse;
       
    34 
       
    35 	CMceSession* session =
       
    36 		reinterpret_cast< CMceSession* >( GetObjectForIdL( KSessionId ) );
       
    37 	// Check that session is in a correct state for sending a response
       
    38 	switch ( session->State() )
       
    39 		{
       
    40 		case CMceSession::EOffering:
       
    41 		case CMceSession::EReserving:
       
    42 		case CMceSession::EAnswering:
       
    43 		case CMceSession::EProceeding:
       
    44 		case CMceSession::EEstablished:
       
    45 			break;
       
    46 		
       
    47 		default:
       
    48 			User::Leave( KErrArgument );
       
    49 		}
       
    50 
       
    51 	TMceTransactionId transactionId = ExtractIntegerL( KParamTransactionId );
       
    52 
       
    53 	// Get reason phrase
       
    54 	TPtrC8 reasonPhrase = ExtractTextL( KParamReasonPhrase );
       
    55 
       
    56 	// Get status code
       
    57 	TInt statusCode = ExtractIntegerL( KParamStatusCode );
       
    58 
       
    59 	// Get Headers
       
    60 	CDesC8Array* headers = ExtractHeadersL( KOptional );
       
    61 	CleanupStack::PushL( headers );
       
    62 	
       
    63 	// Get ContentType
       
    64 	HBufC8* contentType = HBufCParameterL( ExtractTextL( KParamContentType, 
       
    65 													     KOptional ) );
       
    66 	CleanupStack::PushL( contentType );
       
    67 	
       
    68 	// Get Body
       
    69 	HBufC8* body = HBufCParameterL( ExtractTextL( KParamBody, KOptional ) );
       
    70 	CleanupStack::PushL( body );
       
    71 
       
    72 	// ---------- Execution ----------------------------------------------------
       
    73 
       
    74 	session->SendResponseL( transactionId,
       
    75 				      		reasonPhrase,
       
    76 			          		statusCode,
       
    77 				      		headers,
       
    78 				      		contentType,
       
    79 				      		body );
       
    80 	CleanupStack::Pop( body );
       
    81     CleanupStack::Pop( contentType );
       
    82     CleanupStack::Pop( headers );
       
    83     
       
    84 	// ---------- Response creation --------------------------------------------
       
    85  
       
    86 	// No output ids or output params
       
    87     }
       
    88 
       
    89 // -----------------------------------------------------------------------------
       
    90 // TCmdSendResponse::Match
       
    91 // -----------------------------------------------------------------------------
       
    92 //
       
    93 TBool TCmdSendResponse::Match( const TTcIdentifier& aId )
       
    94 	{
       
    95 	return TTcMceCommandBase::Match( aId, _L8( "SendResponse" ) );
       
    96 	}
       
    97 
       
    98 // -----------------------------------------------------------------------------
       
    99 // TCmdSendResponse::CreateL
       
   100 // -----------------------------------------------------------------------------
       
   101 //
       
   102 TTcCommandBase* TCmdSendResponse::CreateL( MTcTestContext& aContext )
       
   103 	{
       
   104 	return new ( ELeave ) TCmdSendResponse( aContext );
       
   105 	}