56
|
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 |
// Trace Core
|
|
15 |
|
|
16 |
|
|
17 |
#include "TraceCore.h"
|
|
18 |
#include "TraceCoreSubscriber.h"
|
|
19 |
#include "TraceCoreRouter.h"
|
|
20 |
#include "TraceCoreDebug.h"
|
|
21 |
#include "OstTraceDefinitions.h"
|
|
22 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
23 |
#include "TraceCoreSubscriberTraces.h"
|
|
24 |
#endif
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
/**
|
|
29 |
* Constructor
|
|
30 |
*/
|
|
31 |
EXPORT_C DTraceCoreSubscriber::DTraceCoreSubscriber()
|
|
32 |
: iMessageSender( NULL )
|
|
33 |
{
|
|
34 |
}
|
|
35 |
|
|
36 |
|
|
37 |
/**
|
|
38 |
* Destructor
|
|
39 |
*/
|
|
40 |
EXPORT_C DTraceCoreSubscriber::~DTraceCoreSubscriber()
|
|
41 |
{
|
|
42 |
iMessageSender = NULL;
|
|
43 |
Unsubscribe();
|
|
44 |
}
|
|
45 |
|
|
46 |
/**
|
|
47 |
* Subscribes to a message by message ID / protocol ID
|
|
48 |
* depending of the header format. First byte of aMessageID is always used
|
|
49 |
* for header format.
|
|
50 |
*
|
|
51 |
* @param aMessageId The message ID to be subscribed
|
|
52 |
* @param aMsgFormat Message format e.g. EMessageHeaderFormatOst
|
|
53 |
*
|
|
54 |
*/
|
|
55 |
EXPORT_C TInt DTraceCoreSubscriber::Subscribe( TUint32 aMessageID, TMessageHeaderFormat aHeaderFormat )
|
|
56 |
{
|
|
57 |
TInt ret(KErrNone);
|
|
58 |
// Use MSByte only for header format
|
|
59 |
TUint32 combined = aHeaderFormat << 24 | (aMessageID & 0x00FFFFFF); // CodForChk_Dis_Magic
|
|
60 |
DTraceCoreSubscriber::Subscribe( combined );
|
|
61 |
return ret;
|
|
62 |
}
|
|
63 |
|
|
64 |
/**
|
|
65 |
* Subscribes to a message by message ID
|
|
66 |
*
|
|
67 |
* @param aMessageId The message ID to be subscribed
|
|
68 |
*/
|
|
69 |
EXPORT_C TInt DTraceCoreSubscriber::Subscribe( TUint32 aMessageID )
|
|
70 |
{
|
|
71 |
OstTrace1( TRACE_BORDER, DTRACECORESUBSCRIBER_SUBSCRIBE_ENTRY, "> DTraceCoreSubscriber::Subscribe 0x%x", aMessageID );
|
|
72 |
TInt ret = KErrGeneral;
|
|
73 |
DTraceCore* traceCore = DTraceCore::GetInstance();
|
|
74 |
if ( traceCore != NULL )
|
|
75 |
{
|
|
76 |
TRoutingItem routingItem;
|
|
77 |
|
|
78 |
// If MSByte is empty it is Proprietary message -> Add Proprietary header format id
|
|
79 |
// Otherwise take it from aMessageId (MSByte)
|
|
80 |
if( !(aMessageID & 0xFF000000) ) // CodForChk_Dis_Magic explained in comment
|
|
81 |
{
|
|
82 |
routingItem.iMsgFormat = EMessageHeaderFormatProprietary;
|
|
83 |
}
|
|
84 |
else
|
|
85 |
{
|
|
86 |
// Extract Header Format from aMessageID
|
|
87 |
routingItem.iMsgFormat = (aMessageID >> 24) & 0x000000FF; // CodForChk_Dis_Magic
|
|
88 |
}
|
|
89 |
|
|
90 |
// Remove Header format
|
|
91 |
aMessageID = (aMessageID & 0x00FFFFFF); // CodForChk_Dis_Magic
|
|
92 |
|
|
93 |
routingItem.iMessageID = aMessageID;
|
|
94 |
routingItem.iSubscriber = this;
|
|
95 |
|
|
96 |
ret = traceCore->GetRouter().Subscribe( routingItem );
|
|
97 |
}
|
|
98 |
OstTrace1( TRACE_API, DTRACECORESUBSCRIBER_SUBSCRIBE_EXIT, "DTraceCoreSubscriber::Subscribe. Return code:%d", ret );
|
|
99 |
return ret;
|
|
100 |
}
|
|
101 |
|
|
102 |
|
|
103 |
/**
|
|
104 |
* Unsubscribes a message ID
|
|
105 |
*
|
|
106 |
* @param aMessageId The message ID to be unsubscribed
|
|
107 |
*/
|
|
108 |
EXPORT_C void DTraceCoreSubscriber::Unsubscribe( TUint32 aMessageID )
|
|
109 |
{
|
|
110 |
OstTrace1( TRACE_BORDER, DTRACECORESUBSCRIBER_UNSUBSCRIBE_ENTRY, "> DTraceCoreSubscriber::Unsubscribe. MsgId:%d", aMessageID );
|
|
111 |
DTraceCore* traceCore = DTraceCore::GetInstance();
|
|
112 |
if ( traceCore != NULL )
|
|
113 |
{
|
|
114 |
TRoutingItem routingItem;
|
|
115 |
routingItem.iMessageID = aMessageID;
|
|
116 |
routingItem.iSubscriber = this;
|
|
117 |
traceCore->GetRouter().Unsubscribe( routingItem );
|
|
118 |
}
|
|
119 |
}
|
|
120 |
|
|
121 |
|
|
122 |
/**
|
|
123 |
* Called by router to set the message sender interface
|
|
124 |
*/
|
|
125 |
void DTraceCoreSubscriber::SetMessageSender( MTraceCoreMessageSender& aMessageSender )
|
|
126 |
{
|
|
127 |
iMessageSender = &aMessageSender;
|
|
128 |
}
|
|
129 |
|
|
130 |
|
|
131 |
/**
|
|
132 |
* Unsubscribes all message ID's of this subscriber
|
|
133 |
*/
|
|
134 |
void DTraceCoreSubscriber::Unsubscribe()
|
|
135 |
{
|
|
136 |
DTraceCore* traceCore = DTraceCore::GetInstance();
|
|
137 |
|
|
138 |
// Unsubsribe if TraceCore exists
|
|
139 |
if ( traceCore != NULL )
|
|
140 |
{
|
|
141 |
traceCore->GetRouter().Unsubscribe( *this );
|
|
142 |
}
|
|
143 |
}
|
|
144 |
|
|
145 |
// End of File
|