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