multimediacommsengine/tsrc/MMCTestDriver/MCETester/src/TCmdGetReferState.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 "TCmdGetReferState.h"
       
    22 #include "CTcMCEContext.h"
       
    23 #include <MCERefer.h>
       
    24 
       
    25 void TCmdGetReferState::ExecuteL()
       
    26 	{	
       
    27 	// ---------- Setup --------------------------------------------------------
       
    28 
       
    29 	// Get an item off the receive queue (waits until timeout if none is present)
       
    30 
       
    31 	TInt timeout = ExtractIntegerL( KParamTimeout, KDefaultReceiveTimeout, 
       
    32 									EFalse );
       
    33 									
       
    34 	CTcMCEReceived& item = iContext.ReceivedEventItemL( timeout );	
       
    35 
       
    36 	if ( !item.Refer() ) 
       
    37 		{		
       
    38 		User::Leave(KErrNotFound); // If first item doesn't contain a refer
       
    39 		}
       
    40 
       
    41 	CMceRefer* expectedRefer = reinterpret_cast<CMceRefer*>
       
    42  		(GetObjectForIdL(KReferId, ETrue));
       
    43 	
       
    44 	if( item.Refer() != expectedRefer )
       
    45 		{
       
    46 		// If the first item's containing refer is not the expected
       
    47 		User::Leave(KErrNotFound); 
       
    48 		}		
       
    49 
       
    50 	// ---------- Execution ----------------------------------------------------
       
    51 		
       
    52 	CMceRefer::TState referState = item.ReferState();
       
    53 
       
    54 	// ---------- Response creation --------------------------------------------
       
    55  
       
    56     // Add Refer
       
    57     AddIdResponseL( KReferId, *(item.Refer()) );
       
    58 
       
    59 	// Add state
       
    60 	AddIntegerResponseL( KResponseReferState, referState );
       
    61 	AddTextualReferStateL( referState );    
       
    62 
       
    63 	// Add StatusCode
       
    64 	AddIntegerResponseL(KResponseStatusCode, item.StatusCode());
       
    65 
       
    66 	// Add ReasonPhrase
       
    67 	if (item.ReasonPhrase())
       
    68 		{
       
    69 		if (item.ReasonPhrase()->Length() > 0)
       
    70 			{	
       
    71 			AddTextResponseL(KResponseReasonPhrase, *(item.ReasonPhrase()));	
       
    72 			}
       
    73 		}
       
    74 
       
    75 	// Add Headers
       
    76 	AddHeadersL( item.Headers() );
       
    77 
       
    78 	// Add ContentType
       
    79 	if (item.ContentType())
       
    80 		{
       
    81 		if (item.ContentType()->Length() > 0)
       
    82 			{
       
    83 			AddTextResponseL(KResponseContentType, *(item.ContentType()));
       
    84 			}
       
    85 			
       
    86 		}
       
    87 		
       
    88 	// Add Body
       
    89 	if (item.Body())
       
    90 		{
       
    91 		if (item.Body()->Length() > 0)
       
    92 			{	
       
    93 			AddTextResponseL(KResponseBody, *(item.Body()));	
       
    94 			}
       
    95 		}		
       
    96 	
       
    97 	// Add Error
       
    98 	if ( item.Error() != KErrNone )
       
    99 		{
       
   100 		AddIntegerResponseL( KResponseError, item.Error() );
       
   101 		}	
       
   102 
       
   103 	}
       
   104 	
       
   105 TBool TCmdGetReferState::Match( const TTcIdentifier& aId )
       
   106 	{
       
   107 	return TTcMceCommandBase::Match( aId, _L8("GetReferState") );
       
   108 	}
       
   109 
       
   110 TTcCommandBase* TCmdGetReferState::CreateL( MTcTestContext& aContext )
       
   111 	{
       
   112 	return new( ELeave ) TCmdGetReferState( aContext );
       
   113 	}