tracesrv/tracecore/btrace_handler/src/TraceCorePluginIf.cpp
changeset 56 aa2539c91954
equal deleted inserted replaced
54:a151135b0cf9 56:aa2539c91954
       
     1 // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // TraceCore Plugin Interface
       
    15 // 
       
    16 
       
    17 //- Include Files  ----------------------------------------------------------
       
    18 
       
    19 #include "TraceCorePluginIf.h" 
       
    20 #include "TraceCoreDebug.h"
       
    21 #include "TraceCoreMediaIfCallback.h"
       
    22 #include "TraceCoreMediaPlugin.h"
       
    23 #include "TraceCoreSubscriber.h"
       
    24 #include "OstTraceDefinitions.h"
       
    25 #ifdef OST_TRACE_COMPILER_IN_USE
       
    26 #include "TraceCorePluginIfTraces.h"
       
    27 #endif
       
    28 
       
    29 
       
    30 /**
       
    31  * Constructor
       
    32  */
       
    33 DTraceCorePluginIf::DTraceCorePluginIf()
       
    34 : DTraceCoreMediaIf( KMediaIfSendSupported | KMediaIfPluginSupported )
       
    35 , iMediaPlugin( NULL )
       
    36     {
       
    37     }
       
    38 
       
    39 
       
    40 /**
       
    41  * Destructor
       
    42  */
       
    43 DTraceCorePluginIf::~DTraceCorePluginIf()
       
    44     {
       
    45     iMediaPlugin = NULL;
       
    46     }
       
    47 
       
    48 
       
    49 /**
       
    50  * Initializes the plugin IF
       
    51  *
       
    52  * @param aCallBack Callback to TraceCore
       
    53  */
       
    54 TInt DTraceCorePluginIf::Init( MTraceCoreMediaIfCallback& aCallback )
       
    55     {
       
    56     iCallback = &aCallback;
       
    57     return KErrNone;
       
    58     }
       
    59 
       
    60 /**
       
    61  * Sends messages to plug-in
       
    62  * 
       
    63  * @param aMsg Message to be sent.
       
    64  * @return KErrNone if send successful
       
    65  */
       
    66 TInt DTraceCorePluginIf::Send( TTraceMessage& aMsg )
       
    67     {
       
    68     OstTraceExt1( TRACE_FLOW, DTRACECOREPLUGINIF_SEND_ENTRY, "> DTraceCorePluginIf::Send. MsgId:0x%hhx", aMsg.iMessageId );
       
    69     TInt retval = KErrNotSupported;
       
    70     if ( iMediaPlugin != NULL )
       
    71         {
       
    72         retval = iMediaPlugin->SendMessage( aMsg );
       
    73         }
       
    74     OstTrace1( TRACE_FLOW, DTRACECOREPLUGINIF_SEND_EXIT, "< DTraceCorePluginIf::Send %d", retval );
       
    75     return retval;
       
    76     }
       
    77     
       
    78 
       
    79 /**
       
    80  * Message was received by plug-in
       
    81  * 
       
    82  * @param aMsg The message that was received
       
    83  */
       
    84 void DTraceCorePluginIf::MessageReceived( TTraceMessage &aMsg )
       
    85     {
       
    86     OstTraceExt1( TRACE_FLOW, DTRACECOREPLUGINIF_MESSAGERECEIVED_ENTRY, "> DTraceCorePluginIf::MessageReceived. MsgId:0x%hhx", aMsg.iMessageId );
       
    87     if ( iCallback != NULL )
       
    88         {
       
    89         iCallback->SetSenderMedia( this ); // Added for SPLIT
       
    90         iCallback->MessageReceived( aMsg );
       
    91         }
       
    92     }
       
    93 
       
    94 
       
    95 /**
       
    96  * Registers a media Plug-In
       
    97  */
       
    98 TInt DTraceCorePluginIf::RegisterPlugin( DTraceCoreMediaPlugin& aPlugin )
       
    99     {
       
   100     OstTrace1( TRACE_FLOW, DTRACECOREPLUGINIF_REGISTERPLUGIN_ENTRY, "> DTraceCorePluginIf::RegisterPlugin 0x%x", ( TUint )&( aPlugin ) );
       
   101     TInt retval = KErrNone;
       
   102     
       
   103     // Register given media Plug-In
       
   104     if ( iMediaPlugin == NULL )
       
   105         {
       
   106         iMediaPlugin = &aPlugin;
       
   107         retval = KErrNone;
       
   108         }
       
   109     
       
   110     // Plug-In was already registered
       
   111     else
       
   112         {
       
   113         retval = KErrNotSupported;
       
   114         }
       
   115     OstTrace1( TRACE_FLOW, DTRACECOREPLUGINIF_REGISTERPLUGIN_EXIT, "< DTraceCorePluginIf::RegisterPlugin %d", retval );
       
   116     
       
   117     return retval;
       
   118     }
       
   119 
       
   120 
       
   121 /**
       
   122  * Unregisters a media Plug-In
       
   123  */
       
   124 void DTraceCorePluginIf::UnregisterPlugin( DTraceCoreMediaPlugin& aPlugin )
       
   125     {
       
   126     OstTrace1( TRACE_FLOW, DTRACECOREPLUGINIF_UNREGISTERPLUGIN_ENTRY, "> DTraceCorePluginIf::UnregisterPlugin 0x%x", ( TUint )&( aPlugin ) );
       
   127     
       
   128     // Unregister given media Plug-In
       
   129     if ( iMediaPlugin == &aPlugin )
       
   130         {
       
   131         OstTrace1( TRACE_NORMAL, DTRACECOREPLUGINIF_UNREGISTERPLUGIN_UNREGISTERED, "DTraceCorePluginIf::UnregisterPlugin - Plugin unregistered 0x%x", ( TUint )&( aPlugin ) );
       
   132         iMediaPlugin = NULL;
       
   133         }
       
   134     }
       
   135 
       
   136 // End of File