diff -r a151135b0cf9 -r aa2539c91954 tracesrv/tracecore/btrace_handler/src/TraceCoreSendReceive.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tracesrv/tracecore/btrace_handler/src/TraceCoreSendReceive.cpp Fri Oct 08 14:56:39 2010 +0300 @@ -0,0 +1,222 @@ +// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Trace Core +// + +#include "TraceCoreSendReceive.h" +#include "TraceCorePluginIf.h" +#include "TraceCoreRouter.h" +#include "TraceCoreDebug.h" +#include "TraceCoreOstLddIf.h" +#include "OstTraceDefinitions.h" +#ifdef OST_TRACE_COMPILER_IN_USE +#include "TraceCoreSendReceiveTraces.h" +#endif + + +/** + * Constructor + */ +DTraceCoreSendReceive::DTraceCoreSendReceive() +: iPluginInterface( NULL ) +, iSendInterface( NULL ) +, iMediaWriterInterface( NULL ) +, iReceiver( NULL ) + { + } + + +/** + * Destructor + */ +DTraceCoreSendReceive::~DTraceCoreSendReceive() + { + DeleteInterfaces(); + iReceiver = NULL; + } + + +/** + * Initializer creates the ISA IF and router + */ +TInt DTraceCoreSendReceive::Init( MTraceCoreMessageReceiver& aReceiver ) + { + // Create interfaces + TInt ret = CreateInterfaces(); + if ( ret == KErrNone ) + { + // Initialize all Media interfaces + for ( int i = 0; i < iMediaInterfaces.Count() && ret == KErrNone; i++ ) + { + DTraceCoreMediaIf* mediaIf = iMediaInterfaces[ i ]; + ret = InitMediaInterface( mediaIf ); + } + if ( ret == KErrNone ) + { + iReceiver = &aReceiver; + } + else + { + DeleteInterfaces(); + } + } + TC_TRACE( ETraceLevelFlow, Kern::Printf( "Init( *this ); + if ( ret == KErrNone ) + { + TUint32 flags = aMediaIf->GetFlags(); + // First interface that supports sending is stored as the send interface. + // TODO: Add a TraceCore message which can select the interface used for sending + if ( iSendInterface == NULL && ( flags & KMediaIfSendSupported ) ) + { + iSendInterface = aMediaIf; + } + // First interface that can write traces is stored to iMediaWriterInterface + // TODO: Add a TraceCore message which can select the interface used by the writer + if ( iMediaWriterInterface == NULL && ( flags & KMediaIfSendTraceSupported ) ) + { + iMediaWriterInterface = aMediaIf; + } + // If the plug-in interface is present, it is stored to iPluginInterface + if ( iPluginInterface == NULL && ( flags & KMediaIfPluginSupported ) ) + { + iPluginInterface = static_cast< DTraceCorePluginIf* >( aMediaIf ); + } + } + TC_TRACE( ETraceLevelFlow, Kern::Printf( " DTraceCoreSendReceive::MessageReceived - %d", &aMsg); + TInt ret( KErrNotFound ); + if ( iReceiver != NULL ) + { + ret = iReceiver->MessageReceived( aMsg ); + } + OstTrace1( TRACE_FLOW, DTRACECORESENDRECEIVE_MESSAGERECEIVED_EXIT, "< DTraceCoreSendReceive::MessageReceived - %d",ret); + return ret; + } + +/** + * Set Sender Media + * + * @param Sender media + */ +TInt DTraceCoreSendReceive::SetSenderMedia(DTraceCoreMediaIf* aSenderMedia) + { + if (aSenderMedia != NULL) + { + TUint32 flags = aSenderMedia->GetFlags(); + if (flags & KMediaIfSendSupported) + { + iSendInterface = aSenderMedia; + } + if (flags & KMediaIfSendTraceSupported) + { + iMediaWriterInterface = aSenderMedia; + } + } + return KErrNone; + } + + +/** + * Sends a message to media interface + * + * @param aMessage The message to be sent + */ +TInt DTraceCoreSendReceive::SendMessage( TTraceMessage &aMessage ) + { + TInt retval = KErrGeneral; + if ( iSendInterface != NULL ) + { + // Send the message + retval = iSendInterface->Send( aMessage ); + } + OstTrace1( TRACE_FLOW, DTRACECORESENDRECEIVE_SENDMESSAGE_EXIT, "DTraceCoreSendReceive::SendMessage %d", retval ); + return retval; + } + +// End of File