multimediacommsengine/tsrc/MMCTestDriver/MCETester/src/TCmdCreateEvent.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 "TCmdCreateEvent.h"
       
    22 #include "CTcMCEContext.h"
       
    23 #include <MceOutEvent.h>
       
    24 
       
    25 
       
    26 void TCmdCreateEvent::ExecuteL()
       
    27 	{	
       
    28 	// ---------- Setup --------------------------------------------------------
       
    29 
       
    30 	
       
    31 	// Get profile
       
    32 	CSIPProfile* profile = 
       
    33 		reinterpret_cast<CSIPProfile*>(GetObjectForIdL(KProfileObj, EFalse));
       
    34 		
       
    35 	// Get session
       
    36 	CMceSession* session = 
       
    37 		reinterpret_cast<CMceSession*>(GetObjectForIdL(KSessionId, EFalse));	
       
    38 		
       
    39 	// Get event
       
    40 	CMceEvent* event = 
       
    41 	    reinterpret_cast<CMceEvent*>(GetObjectForIdL(KEventId, EFalse));
       
    42 	    
       
    43 	// Get refer
       
    44 	CMceRefer* refer = 
       
    45 	    reinterpret_cast<CMceRefer*>(GetObjectForIdL(KReferId, EFalse));	
       
    46 				
       
    47 	// Get EventHeader
       
    48 	TPtrC8 eventHeader = ExtractTextL(KParamEventHeader, ETrue);
       
    49 	
       
    50 	// Get refresh interval
       
    51 	TInt refresh = ExtractIntegerL( KParamRefreshInterval, 0, ETrue );
       
    52 	
       
    53 			
       
    54 	// ---------- Execution ----------------------------------------------------
       
    55 
       
    56 	CMceOutEvent* outEvent = NULL;
       
    57 
       
    58 	if ( profile ) 
       
    59 		{
       
    60 		
       
    61 		TPtrC8 recipient = ExtractTextL( KParamRecipient, ETrue );
       
    62 		
       
    63         HBufC8* originator = HBufCParameterL(ExtractTextL( KParamOriginator, 
       
    64                                                            EFalse));
       
    65 	    CleanupStack::PushL( originator );
       
    66 			
       
    67 		outEvent = CMceOutEvent::NewL( iContext.MCEManager(), 
       
    68 		                               *profile,
       
    69 		                               recipient,
       
    70 		                               eventHeader,
       
    71 		                               refresh,
       
    72 		                               originator );
       
    73 		                               
       
    74 		CleanupStack::Pop( originator );
       
    75 		}
       
    76 	else if ( session ) 
       
    77 		{
       
    78 		outEvent = CMceOutEvent::NewL( *session,
       
    79 		                               eventHeader,
       
    80 		                               refresh );
       
    81 		}
       
    82 	else if ( event ) 
       
    83 		{
       
    84 		outEvent = CMceOutEvent::NewL( *event,
       
    85 		                               eventHeader,
       
    86 		                               refresh );
       
    87 		}
       
    88 	else if ( refer )
       
    89 	    {
       
    90 		outEvent = CMceOutEvent::NewL( *refer,
       
    91 		                               eventHeader,
       
    92 		                               refresh );	    
       
    93 	    }
       
    94     else
       
    95     	{
       
    96 		User::Leave( KErrNotFound );
       
    97 		}
       
    98 		
       
    99 	// ---------- Response creation --------------------------------------------
       
   100 
       
   101 	// Must be added by pointer, ownership is transferred to object registry.
       
   102  	AddIdResponseL(KEventId, outEvent);
       
   103 
       
   104 
       
   105 	}
       
   106 	
       
   107 TBool TCmdCreateEvent::Match( const TTcIdentifier& aId )
       
   108 	{
       
   109 	return TTcMceCommandBase::Match( aId, _L8("CreateEvent") );
       
   110 	}
       
   111 
       
   112 TTcCommandBase* TCmdCreateEvent::CreateL( MTcTestContext& aContext )
       
   113 	{
       
   114 	return new( ELeave ) TCmdCreateEvent( aContext );
       
   115 	}