multimediacommsengine/tsrc/MMCTestDriver/MCETester/src/TCmdSendRequest.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 "TCmdSendRequest.h"
       
    22 #include "CTcMCEContext.h"
       
    23 #include "mcesession.h"
       
    24 
       
    25 // -----------------------------------------------------------------------------
       
    26 // TCmdSendRequest::ExecuteL
       
    27 // -----------------------------------------------------------------------------
       
    28 //
       
    29 void TCmdSendRequest::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 request
       
    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 		
       
    52 	// Get request method
       
    53 	TPtrC8 method = ExtractTextL( KParamMethod );
       
    54 
       
    55 	// Get Headers
       
    56 	CDesC8Array* headers = ExtractHeadersL( KOptional );
       
    57 	CleanupStack::PushL( headers );
       
    58 	
       
    59 	// Get ContentType
       
    60 	HBufC8* contentType = HBufCParameterL( ExtractTextL( KParamContentType, 
       
    61 													     KOptional ) );
       
    62 	CleanupStack::PushL( contentType );
       
    63 	
       
    64 	// Get Body
       
    65 	HBufC8* body = HBufCParameterL( ExtractTextL( KParamBody, KOptional ) );
       
    66 	CleanupStack::PushL( body );
       
    67 
       
    68 	// ---------- Execution ----------------------------------------------------
       
    69 
       
    70 	TMceTransactionId transactionId =
       
    71 		session->SendRequestL( method, headers, contentType, body );
       
    72 
       
    73 	CleanupStack::Pop( body );
       
    74     CleanupStack::Pop( contentType );
       
    75     CleanupStack::Pop( headers );
       
    76 
       
    77 	// ---------- Response creation --------------------------------------------
       
    78 
       
    79 	AddIntegerResponseL( KResponseTransactionId, transactionId );
       
    80     }
       
    81 
       
    82 // -----------------------------------------------------------------------------
       
    83 // TCmdSendRequest::Match
       
    84 // -----------------------------------------------------------------------------
       
    85 //
       
    86 TBool TCmdSendRequest::Match( const TTcIdentifier& aId )
       
    87 	{
       
    88 	return TTcMceCommandBase::Match( aId, _L8( "SendRequest" ) );
       
    89 	}
       
    90 
       
    91 // -----------------------------------------------------------------------------
       
    92 // TCmdSendRequest::CreateL
       
    93 // -----------------------------------------------------------------------------
       
    94 //
       
    95 TTcCommandBase* TCmdSendRequest::CreateL( MTcTestContext& aContext )
       
    96 	{
       
    97 	return new ( ELeave ) TCmdSendRequest( aContext );
       
    98 	}