multimediacommsengine/tsrc/testdriver/siptester/src/TCmdSendResponse.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 <sipresponseelements.h>
       
    19 #include <sipservertransaction.h>
       
    20 #include <sipstrings.h>
       
    21 #include <stringpool.h>
       
    22 #include <_sipcodecdefs.h>
       
    23 
       
    24 #include "TCmdSendResponse.h"
       
    25 #include "SIPConstants.h"
       
    26 
       
    27 /**
       
    28  * INPUT:
       
    29  *   Headers:		Contact*, Content-Type*, Content-Encoding*
       
    30  *   Parameters:	StatusCode, Reason, Content*
       
    31  *   IDs:			ServerTransactionId
       
    32  *
       
    33  * OUTPUT:
       
    34  *   Parameters:	-
       
    35  *   IDs:			-
       
    36  */
       
    37 void TCmdSendResponse::ExecuteL()
       
    38 	{
       
    39 	// -- Setup ---------------------------------------------------------------
       
    40 
       
    41 	// Get SIP objects from registry
       
    42 	CSIPServerTransaction* serverTransaction = GetServerTransactionL();
       
    43 
       
    44 	// Get StatusCode and Reason
       
    45 	TInt statusCode = ExtractIntegerL( KParamStatusCode );
       
    46 	TPtrC8 reasonPtr = ExtractTextL( KParamReason );
       
    47 	RStringF reasonStr = SIPStrings::Pool().OpenFStringL(reasonPtr);
       
    48 	CleanupClosePushL(reasonStr);
       
    49 
       
    50 	// Create SIP response elements
       
    51 	CSIPResponseElements* resElements =
       
    52 							CSIPResponseElements::NewLC( statusCode, reasonStr );
       
    53 	
       
    54 	// Extract both headers (that are still left) and content.
       
    55 	ExtractHeadersAndContentL( resElements->MessageElements() );
       
    56 
       
    57 	// -- Execution -----------------------------------------------------------
       
    58 
       
    59 	// Send SIP Response
       
    60 	serverTransaction->SendResponseL( resElements );
       
    61 	CleanupStack::Pop( resElements );
       
    62 	CleanupStack::PopAndDestroy(); // reasonStr
       
    63 	
       
    64 	// -- Response creation ---------------------------------------------------
       
    65 	}
       
    66 
       
    67 TBool TCmdSendResponse::Match( const TTcIdentifier& aId )
       
    68 	{
       
    69 	return TTcSIPCommandBase::Match( aId, _L8("SendResponse") );
       
    70 	}
       
    71 
       
    72 TTcCommandBase* TCmdSendResponse::CreateL( MTcTestContext& aContext )
       
    73 	{
       
    74 	return new( ELeave ) TCmdSendResponse( aContext );
       
    75 	}
       
    76