multimediacommsengine/tsrc/MMCTestDriver/MCETester/src/TCmdGetEventId.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 "TCmdGetEventId.h"
       
    22 #include "CTcMCEContext.h"
       
    23 
       
    24 #include <MCEEvent.h>
       
    25 #include <MceInEvent.h>
       
    26 
       
    27 void TCmdGetEventId::ExecuteL()
       
    28 	{	
       
    29 	// ---------- Setup --------------------------------------------------------
       
    30 
       
    31 
       
    32 
       
    33 	// ---------- Execution ----------------------------------------------------
       
    34 
       
    35 	// Get an item off the receive queue (waits until timeout if none is present)
       
    36 
       
    37 	TInt timeout = ExtractIntegerL( KParamTimeout, KDefaultReceiveTimeout, 
       
    38 									EFalse );
       
    39 									
       
    40 	CTcMCEReceived& item = iContext.ReceivedEventItemL( timeout );	
       
    41 	
       
    42 	if ( !item.InEvent() ) 
       
    43 		{		
       
    44 		User::Leave(KErrNotFound); // If first item doesn't contain an event
       
    45 		}
       
    46 		
       
    47 	CMceEvent::TState eventState = item.InEvent()->State();
       
    48 	// ---------- Response creation --------------------------------------------
       
    49  
       
    50  	// Add Event
       
    51  	AddIdResponseL( KEventId, *item.InEvent() );
       
    52  	
       
    53 	// Add Headers
       
    54 	AddHeadersL( item.Headers() );	
       
    55 					
       
    56 	// Add ContentType
       
    57 	if (item.ContentType())
       
    58 		{
       
    59 		if (item.ContentType()->Length() > 0)
       
    60 			{
       
    61 			AddTextResponseL(KResponseContentType, *(item.ContentType()));
       
    62 			}
       
    63 		}
       
    64 
       
    65 	// Add Body
       
    66 	if (item.Body())
       
    67 		{
       
    68 		if (item.Body()->Length() > 0)
       
    69 			{	
       
    70 			AddTextResponseL(KResponseBody, *(item.Body()));	
       
    71 			}
       
    72 		}
       
    73 	
       
    74 	// Add event state	
       
    75 	AddIntegerResponseL( KResponseEventState, eventState );
       
    76 	AddTextualEventStateL( eventState );
       
    77 		
       
    78 	}
       
    79 	
       
    80 TBool TCmdGetEventId::Match( const TTcIdentifier& aId )
       
    81 	{
       
    82 	return TTcMceCommandBase::Match( aId, _L8("GetEventId") );
       
    83 	}
       
    84 
       
    85 TTcCommandBase* TCmdGetEventId::CreateL( MTcTestContext& aContext )
       
    86 	{
       
    87 	return new( ELeave ) TCmdGetEventId( aContext );
       
    88 	}