sdkcreationmw/sdkruntimes/emulatorplugins/test/EcmtTestPlugin.cpp
changeset 0 b26acd06ea60
equal deleted inserted replaced
-1:000000000000 0:b26acd06ea60
       
     1 /*
       
     2 * Copyright (c) 2009 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:
       
    15 *
       
    16 */
       
    17 #include <ecom.h>
       
    18 #include <ImplementationProxy.h>
       
    19 #include "EcmtTestPlugin.h"
       
    20 #include "EcmtTestPluginUids.h"
       
    21 #include "EcmtMessageEvent.h"
       
    22 
       
    23 TUid CTestPlugin::GetUid()
       
    24 	{
       
    25 	return iUid;
       
    26 	}
       
    27 
       
    28 CTestPlugin::CTestPlugin() : 
       
    29 	CTimer( EPriorityStandard ),
       
    30 	iUid( TUid::Uid( KTESTPLUGIN_IMPL_UID ) ),
       
    31 	iTargetUid( TUid::Uid( KJAVA_TESTPLUGIN_IMPL_UID ) ),
       
    32 	iInterval( 5000000 )
       
    33 	{
       
    34 	
       
    35 	}
       
    36 	
       
    37 CTestPlugin::~CTestPlugin()
       
    38 	{
       
    39 	
       
    40 	}
       
    41 	
       
    42 void CTestPlugin::BindMessagingL( MEcmtMessaging* aMessaging )
       
    43 	{
       
    44 	iMessaging = aMessaging;
       
    45 	iMessaging->AddMessageEventObserverL( *this, iUid );
       
    46 	iMessageSender = iMessaging->GetMessageSender( );
       
    47 	}
       
    48 
       
    49 void CTestPlugin::ConstructL()
       
    50 	{
       
    51 	CTimer::ConstructL();
       
    52 	CActiveScheduler::Add(this);	
       
    53 	After( iInterval );
       
    54 	}
       
    55 
       
    56 MEcmtPlugin* CTestPlugin::NewL( )
       
    57 	{
       
    58     CTestPlugin* self = new( ELeave ) CTestPlugin;
       
    59     CleanupStack::PushL( self );
       
    60     self->ConstructL( );
       
    61     
       
    62     CleanupStack::Pop();
       
    63     return self;
       
    64 	}
       
    65 	
       
    66 void CTestPlugin::HandleNotifyL( const CEcmtMessageEvent& aEvent )
       
    67 	{
       
    68 	const TPtrC8 m = iMessaging->Message( aEvent );
       
    69 	TLex8 lexer( m );
       
    70 	
       
    71 	TInt newInterval;
       
    72 	if ( lexer.Val( newInterval ) == KErrNone && newInterval > 1000 )
       
    73 		{
       
    74 		iInterval = newInterval;
       
    75 		}
       
    76 	}
       
    77 	
       
    78 void CTestPlugin::RunL( )
       
    79 	{
       
    80     if (iStatus == KErrNone)
       
    81     	{
       
    82     	TBuf8<256> msg;
       
    83     	
       
    84     	msg.Append( _L("Count is now: ") );
       
    85     	msg.AppendNum( iCount++ );
       
    86 	msg.Append( _L("\n\r") );
       
    87     	
       
    88 		CEcmtMessageEvent* m = iMessaging->NewMessageEvent( iTargetUid, msg );
       
    89 		if ( m )
       
    90 			{
       
    91 			iMessageSender->SendMessage( m );
       
    92 			}
       
    93 		After( iInterval );
       
    94     	}
       
    95 	}
       
    96 
       
    97 
       
    98 /**
       
    99 *	Bulk code needed by ECom and Symbian OS frameworks
       
   100 */
       
   101 const TImplementationProxy ImplementationTable[] = 
       
   102 	{
       
   103 		{ {KTESTPLUGIN_IMPL_UID}, CTestPlugin::NewL}
       
   104 	};
       
   105 
       
   106 // Exported proxy for instantiation method resolution
       
   107 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
       
   108 	{
       
   109 	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
       
   110 
       
   111 	return ImplementationTable;
       
   112 	}
       
   113