multimediacommsengine/tsrc/MMCTestDriver/MCETester/src/TCmdGetMessage.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 "TCmdGetMessage.h"
       
    22 #include "CTcMCEContext.h"
       
    23 #include <MCESession.h>
       
    24 #include <MCEEvent.h>
       
    25 
       
    26 
       
    27 void TCmdGetMessage::ExecuteL()
       
    28 	{
       
    29 	
       
    30 	// -- Setup ---------
       
    31 	
       
    32 
       
    33 	// -- Execution ------
       
    34 	
       
    35 	// Get an item off the receive queue (waits until timeout if none is present)
       
    36 	TInt timeout = ExtractIntegerL( KParamTimeout, KDefaultReceiveTimeout, EFalse );
       
    37 	CTcMCEReceived& item = iContext.ReceivedSessionItemL( timeout );
       
    38 		
       
    39 	// -- Response creation --------	
       
    40 	
       
    41 	// Add Session
       
    42 	if ( item.Session() )
       
    43 		{
       
    44 		AddIdResponseL( KSessionId, *(item.Session()) );
       
    45 		}
       
    46 
       
    47 	if ( item.InSession() )
       
    48 		{
       
    49 		AddIdResponseL( KSessionId, *(item.Session()) );
       
    50 		}
       
    51 
       
    52 	// Add Headers
       
    53 	AddHeadersL( item.Headers() ); 
       
    54 
       
    55 	// Add ContentType
       
    56 	if (item.ContentType())
       
    57 		{
       
    58 		if (item.ContentType()->Length() > 0)
       
    59 			{
       
    60 			AddTextResponseL(KResponseContentType, *(item.ContentType()));
       
    61 			}
       
    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 StatusCode
       
    75 	if ( item.StatusCode() != 0 )
       
    76 		{
       
    77 		AddIntegerResponseL(KResponseStatusCode, item.StatusCode());		
       
    78 		}
       
    79 		
       
    80 	// Add ReasonPhrase				
       
    81 	if (item.ReasonPhrase())
       
    82 		{
       
    83 		if (item.ReasonPhrase()->Length() > 0)
       
    84 			{	
       
    85 			AddTextResponseL(KResponseReasonPhrase, 
       
    86 				 			 *(item.ReasonPhrase()));	
       
    87 			}
       
    88 		}
       
    89 
       
    90 	// Add FCMessage
       
    91 	if (item.FCMessage())
       
    92 		{
       
    93 		if (item.FCMessage()->Length() > 0)
       
    94 			{	
       
    95 			AddTextResponseL(KResponseFCMessage, *(item.FCMessage()));	
       
    96 			}
       
    97 		}		
       
    98 	
       
    99 	// Add event Id
       
   100 	if ( item.Event() )
       
   101 		{
       
   102 		AddIdResponseL( KEventId, item.Event() );
       
   103 		}
       
   104 
       
   105 	if ( item.InEvent() )
       
   106 		{
       
   107 		AddIdResponseL( KEventId, item.Event() );		
       
   108 		}
       
   109 
       
   110 	// Add ReferTo-header
       
   111 	if ( item.ReferTo() != KNullDesC8 )
       
   112 		{
       
   113 		AddTextResponseL( KResponseReferTo, item.ReferTo() );
       
   114 		}
       
   115 		
       
   116 	// Add Error
       
   117 	if ( item.Error() != KErrNone )
       
   118 		{
       
   119 		AddIntegerResponseL( KResponseError, item.Error() );
       
   120 		}		
       
   121 
       
   122 	// Add Request method
       
   123 	if ( item.Method() )
       
   124 		{
       
   125 		AddTextResponseL( KResponseMethod, *item.Method() );
       
   126 		}
       
   127 
       
   128 	// Add transaction id
       
   129 	if ( item.TransactionId() )
       
   130 		{
       
   131 		AddIntegerResponseL( KResponseTransactionId, item.TransactionId() );
       
   132 		}
       
   133 	}
       
   134 
       
   135 TBool TCmdGetMessage::Match( const TTcIdentifier& aId )
       
   136 	{
       
   137 	return TTcMceCommandBase::Match( aId, _L8("GetMessage") );
       
   138 	}
       
   139 
       
   140 TTcCommandBase* TCmdGetMessage::CreateL( MTcTestContext& aContext )
       
   141 	{
       
   142 	return new( ELeave ) TCmdGetMessage( aContext );
       
   143 	}