multimediacommsengine/tsrc/MMCTestDriver/MCETester/src/TCmdSendAcceptSession.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2005 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 "TCmdSendAcceptSession.h"
       
    22 #include "CTcMCEContext.h"
       
    23 #include <MceInSession.h>
       
    24 #include "CTcMCEFloorControlObserver.h"
       
    25 
       
    26 void TCmdSendAcceptSession::ExecuteL()
       
    27 	{	
       
    28 	// ---------- Setup ------------------------------------
       
    29 	
       
    30 	// Get session
       
    31 	CMceInSession* session = reinterpret_cast<CMceInSession*>
       
    32 		(GetObjectForIdL(KSessionId, ETrue));	
       
    33 	
       
    34 	// ---------- Execution --------------------------------
       
    35 
       
    36 	// Get reasonphrase
       
    37 	TPtrC8 reason = ExtractTextL(KParamReasonPhrase, EFalse);
       
    38 		
       
    39 	// Get statuscode
       
    40 	TInt status = ExtractIntegerL(KParamStatusCode, 0, EFalse);
       
    41 	
       
    42 	// Get Headers
       
    43 	//CDesC8Array* headers = ExtractHeadersL( EFalse );
       
    44 	//CleanupStack::PushL(headers);
       
    45 	
       
    46 	// Floor control usage
       
    47 	TBool useFC = ExtractBooleanL( KParamUseFloorControl, EFalse );
       
    48 	
       
    49 
       
    50 
       
    51 	if ( useFC )
       
    52 		{
       
    53 		TInt fcPort = ExtractIntegerL(KParamFCPort,2000, EFalse);
       
    54 	 	iContext.FC().InitializeL( *session, fcPort, iContext.FCObserver() );
       
    55 		// Floor control preparations
       
    56 		MDesC8Array* mediaAttrLines = iContext.FC().MediaAttributeLinesL(*session);
       
    57 		CDesC8Array* tmpArray = new (ELeave) CDesC8ArrayFlat(1);
       
    58 		CleanupStack::PushL(tmpArray);
       
    59 		if (mediaAttrLines->MdcaCount()>0)
       
    60 			{
       
    61 			for (TInt i = 0; i < mediaAttrLines->MdcaCount(); i++)
       
    62 				{
       
    63 				tmpArray->AppendL(mediaAttrLines->MdcaPoint(i));
       
    64 				}
       
    65 			}
       
    66 		iContext.FC().UpdateL( *session, tmpArray );
       
    67 		CleanupStack::Pop();
       
    68 		delete mediaAttrLines;
       
    69 		}
       
    70 
       
    71 	// Accept
       
    72 	if ( reason == KNullDesC8 && status == 0 )
       
    73 		{
       
    74 		session->AcceptL();
       
    75 		}
       
    76 	else
       
    77 		{
       
    78 		session->AcceptL(reason, status);
       
    79 		}
       
    80 
       
    81 	CMceSession::TState state = session->State();			
       
    82 
       
    83 	// ---------- Response creation -----------------------
       
    84  
       
    85 	AddIdResponseL( KSessionId, *session );
       
    86 
       
    87 	// Add Session state	
       
    88 	AddIntegerResponseL( KResponseState, state );
       
    89 	AddTextualSessionStateL( state );		
       
    90 	}
       
    91 	
       
    92 TBool TCmdSendAcceptSession::Match( const TTcIdentifier& aId )
       
    93 	{
       
    94 	return TTcMceCommandBase::Match( aId, _L8("SendAnswer") );
       
    95 	}
       
    96 
       
    97 TTcCommandBase* TCmdSendAcceptSession::CreateL( MTcTestContext& aContext )
       
    98 	{
       
    99 	return new( ELeave ) TCmdSendAcceptSession( aContext );
       
   100 	}