0
|
1 |
/*
|
|
2 |
* Copyright (c) 2007-2008 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 the License "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 |
|
|
18 |
|
|
19 |
|
|
20 |
// INCLUDE FILES
|
|
21 |
#include <tisi.h>
|
|
22 |
#include "cmmphonetreceiver.h"
|
|
23 |
#include <ctsy/serviceapi/mmtsy_defaults.h>
|
|
24 |
|
|
25 |
// For logging purposes
|
|
26 |
#include "tsylogger.h"
|
|
27 |
|
|
28 |
// ISA CellMo ATK server
|
|
29 |
#include <pn_const.h>
|
|
30 |
#include "osttracedefinitions.h"
|
|
31 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
32 |
#include "cmmphonetreceivertraces.h"
|
|
33 |
#endif
|
|
34 |
|
|
35 |
// EXTERNAL DATA STRUCTURES
|
|
36 |
// None
|
|
37 |
|
|
38 |
// EXTERNAL FUNCTION PROTOTYPES
|
|
39 |
// None
|
|
40 |
|
|
41 |
// CONSTANTS
|
|
42 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
43 |
const TUint8 KBufferForOSTTracing = 100;
|
|
44 |
#endif
|
|
45 |
#ifdef TF_LOGGING_ENABLED
|
|
46 |
const TUint8 KBufferForTFLogging = 130;
|
|
47 |
#endif
|
|
48 |
|
|
49 |
// MACROS
|
|
50 |
// None
|
|
51 |
|
|
52 |
// LOCAL CONSTANTS AND MACROS
|
|
53 |
// None
|
|
54 |
|
|
55 |
// MODULE DATA STRUCTURES
|
|
56 |
// None
|
|
57 |
|
|
58 |
// LOCAL FUNCTION PROTOTYPES
|
|
59 |
//None
|
|
60 |
|
|
61 |
// ======================= LOCAL FUNCTIONS =====================================
|
|
62 |
|
|
63 |
// -----------------------------------------------------------------------------
|
|
64 |
// TFLOG_PRINT_ISIMESSAGE
|
|
65 |
// local function for priting ISI message contents
|
|
66 |
// -----------------------------------------------------------------------------
|
|
67 |
//
|
|
68 |
#if defined (TF_LOGGING_ENABLED) || defined (OST_TRACE_COMPILER_IN_USE)
|
|
69 |
static void TFLOG_PRINT_ISIMESSAGE( const TDesC8& aBuf )
|
|
70 |
{
|
|
71 |
_LIT( KTraceSpace, " " );
|
|
72 |
|
|
73 |
// Get the length of the ISI message
|
|
74 |
TInt length = aBuf.Length();
|
|
75 |
|
|
76 |
#ifdef TF_LOGGING_ENABLED
|
|
77 |
TBuf<KBufferForTFLogging> msg;
|
|
78 |
_LIT( KTracePhonetReceiver, "TSY:Phonet Receiver: [ " );
|
|
79 |
_LIT( KTraceBracketClose, "]" );
|
|
80 |
|
|
81 |
msg.Append( KTracePhonetReceiver );
|
|
82 |
|
|
83 |
if ( 250 < length )
|
|
84 |
{
|
|
85 |
// Print only 250 first bytes
|
|
86 |
length = 250;
|
|
87 |
}
|
|
88 |
|
|
89 |
for ( TInt i = 0; i < length; i++ )
|
|
90 |
{
|
|
91 |
msg.AppendNumFixedWidthUC( aBuf[i], EHex, 2 );
|
|
92 |
msg.Append( KTraceSpace );
|
|
93 |
if ( KLogSizeOfBuffer-10 < msg.Length() )
|
|
94 |
{
|
|
95 |
if ( i == ( length - 1 ) )
|
|
96 |
{
|
|
97 |
// Last number, append "]" character
|
|
98 |
msg.Append( KTraceBracketClose );
|
|
99 |
}
|
|
100 |
|
|
101 |
TFLOGTEXT( msg );
|
|
102 |
msg.SetLength( 0 );
|
|
103 |
}
|
|
104 |
}
|
|
105 |
|
|
106 |
if ( 0 < msg.Length() )
|
|
107 |
{
|
|
108 |
// Buffer contains data. Print also last line
|
|
109 |
msg.Append( KTraceBracketClose );
|
|
110 |
TFLOGTEXT( msg );
|
|
111 |
}
|
|
112 |
#endif // TF_LOGGING_ENABLED
|
|
113 |
|
|
114 |
// Ost tracing
|
|
115 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
116 |
TBuf8<KBufferForOSTTracing> trace_msg;
|
|
117 |
TUint8 counter = 1;
|
|
118 |
TBool firstTime = ETrue;
|
|
119 |
for ( TInt i = 0; i < length; i++ )
|
|
120 |
{
|
|
121 |
trace_msg.AppendNumFixedWidthUC( aBuf[i], EHex, 2 );
|
|
122 |
trace_msg.Append( KTraceSpace );
|
|
123 |
|
|
124 |
if ( ( counter > 24 ) || // 25 bytes / line
|
|
125 |
( ( i + 1 ) == length ) ) // All bytes collected
|
|
126 |
{
|
|
127 |
if ( ( firstTime ) &&
|
|
128 |
( ( i + 1 ) == length ) ) // All bytes collected and traced
|
|
129 |
{
|
|
130 |
firstTime = EFalse;
|
|
131 |
OstTraceExt1( TRACE_NORMAL, DUP2__TFLOG_PRINT_ISIMESSAGE, "Phonet Receiver: [ %s]", trace_msg );
|
|
132 |
trace_msg.SetLength( 0 );
|
|
133 |
}
|
|
134 |
else if ( firstTime ) // 1st line of the trace
|
|
135 |
{
|
|
136 |
firstTime = EFalse;
|
|
137 |
OstTraceExt1( TRACE_NORMAL, DUP3__TFLOG_PRINT_ISIMESSAGE, "Phonet Receiver: [ %s", trace_msg );
|
|
138 |
trace_msg.SetLength( 0 );
|
|
139 |
}
|
|
140 |
else if ( ( i + 1 ) == length ) // The last line
|
|
141 |
{
|
|
142 |
OstTraceExt1( TRACE_NORMAL, DUP4_TFLOG_PRINT_ISIMESSAGE, "Phonet Receiver: %s]", trace_msg );
|
|
143 |
trace_msg.SetLength( 0 );
|
|
144 |
}
|
|
145 |
else // just print bytes
|
|
146 |
{
|
|
147 |
OstTraceExt1( TRACE_NORMAL, DUP5_TFLOG_PRINT_ISIMESSAGE, "Phonet Receiver: %s", trace_msg );
|
|
148 |
trace_msg.SetLength( 0 );
|
|
149 |
}
|
|
150 |
counter = 0;
|
|
151 |
}
|
|
152 |
counter++;
|
|
153 |
}
|
|
154 |
#endif // OST_TRACE_COMPILER_IN_USE
|
|
155 |
|
|
156 |
}
|
|
157 |
|
|
158 |
#else // TF_LOGGING_ENABLED || OST_TRACE_COMPILER_IN_USE
|
|
159 |
|
|
160 |
#define TFLOG_PRINT_ISIMESSAGE(x)
|
|
161 |
|
|
162 |
#endif // TF_LOGGING_ENABLED || OST_TRACE_COMPILER_IN_USE
|
|
163 |
|
|
164 |
// ==================== MEMBER FUNCTIONS =======================================
|
|
165 |
|
|
166 |
// -----------------------------------------------------------------------------
|
|
167 |
// CMmPhoNetReceiver::CMmPhoNetReceiver
|
|
168 |
// C++ default constructor
|
|
169 |
// -----------------------------------------------------------------------------
|
|
170 |
//
|
|
171 |
CMmPhoNetReceiver::CMmPhoNetReceiver()
|
|
172 |
: CActive( 0 ),
|
|
173 |
iMessageReceiver( NULL ),
|
|
174 |
iMessageBuffer( NULL ),
|
|
175 |
iMessageBufferPtr( 0,0 ),
|
|
176 |
iNeededBufferLength( 0 ),
|
|
177 |
iSatMessHandler( NULL ),
|
|
178 |
iSatMessageBuffer( NULL )
|
|
179 |
{
|
|
180 |
TFLOGSTRING("TSY: CMmPhoNetReceiver::CMmPhoNetReceiver");
|
|
181 |
OstTrace0( TRACE_NORMAL, CMMPHONETRECEIVER_CMMPHONETRECEIVER, "CMmPhoNetReceiver::CMmPhoNetReceiver" );
|
|
182 |
//None
|
|
183 |
}
|
|
184 |
|
|
185 |
// -----------------------------------------------------------------------------
|
|
186 |
// CMmPhoNetReceiver::~CMmPhoNetReceiver
|
|
187 |
// Destructor
|
|
188 |
// -----------------------------------------------------------------------------
|
|
189 |
//
|
|
190 |
CMmPhoNetReceiver::~CMmPhoNetReceiver()
|
|
191 |
{
|
|
192 |
TFLOGSTRING("TSY: CMmPhoNetReceiver::~CMmPhoNetReceiver");
|
|
193 |
OstTrace0( TRACE_NORMAL, DUP1_CMMPHONETRECEIVER_CMMPHONETRECEIVER, "CMmPhoNetReceiver::~CMmPhoNetReceiver" );
|
|
194 |
// Shutdown the active scheduler correctly.
|
|
195 |
Cancel();
|
|
196 |
Deque();
|
|
197 |
|
|
198 |
// Closes the array and frees all memory allocated to the array.
|
|
199 |
iMsgReceivers.Close();
|
|
200 |
|
|
201 |
delete iMessageBuffer;
|
|
202 |
delete iSatMessageBuffer;
|
|
203 |
}
|
|
204 |
|
|
205 |
// -----------------------------------------------------------------------------
|
|
206 |
// CMmPhoNetReceiver::NewL
|
|
207 |
// Two-phased constructor.
|
|
208 |
// Creates a new CMmPhoNetReceiver object instance. If either
|
|
209 |
// mmPhone or phonet received as parameters is NULL, CMmPhoNetReceiver will
|
|
210 |
// not be created and NULL will be returned.
|
|
211 |
// -----------------------------------------------------------------------------
|
|
212 |
//
|
|
213 |
CMmPhoNetReceiver* CMmPhoNetReceiver::NewL
|
|
214 |
(
|
|
215 |
RIscApi* aPn // Phonet
|
|
216 |
)
|
|
217 |
{
|
|
218 |
TFLOGSTRING("TSY: CMmPhoNetReceiver::NewL");
|
|
219 |
OstTrace0( TRACE_NORMAL, CMMPHONETRECEIVER_NEWL, "CMmPhoNetReceiver::NewL" );
|
|
220 |
|
|
221 |
CMmPhoNetReceiver* phoNetReceiver = NULL;
|
|
222 |
|
|
223 |
if ( NULL != aPn )
|
|
224 |
{
|
|
225 |
phoNetReceiver = new ( ELeave ) CMmPhoNetReceiver();
|
|
226 |
|
|
227 |
CleanupStack::PushL( phoNetReceiver );
|
|
228 |
phoNetReceiver->ConstructL();
|
|
229 |
CleanupStack::Pop( phoNetReceiver );
|
|
230 |
|
|
231 |
// Set pointer to the Phonet
|
|
232 |
phoNetReceiver->iPhoNet = aPn;
|
|
233 |
|
|
234 |
// Adds the specified active object to the current active scheduler
|
|
235 |
CActiveScheduler::Add( phoNetReceiver );
|
|
236 |
}
|
|
237 |
|
|
238 |
return phoNetReceiver;
|
|
239 |
}
|
|
240 |
|
|
241 |
// -----------------------------------------------------------------------------
|
|
242 |
// CMmPhoNetReceiver::ConstructL
|
|
243 |
// Symbian 2nd phase constructor.
|
|
244 |
// -----------------------------------------------------------------------------
|
|
245 |
//
|
|
246 |
void CMmPhoNetReceiver::ConstructL()
|
|
247 |
{
|
|
248 |
// Allocate memory for incoming message.
|
|
249 |
TFLOGSTRING("TSY: CMmPhoNetReceiver::ConstructL");
|
|
250 |
OstTrace0( TRACE_NORMAL, CMMPHONETRECEIVER_CONSTRUCTL, "CMmPhoNetReceiver::ConstructL" );
|
|
251 |
|
|
252 |
iMessageBuffer = HBufC8::NewL( KDefaultReceiveBufferSize );
|
|
253 |
iMessageBufferPtr.Set( iMessageBuffer->Des() );
|
|
254 |
|
|
255 |
TFLOGSTRING2("TSY: iMessageBuffer len=%d", iMessageBuffer->Length());
|
|
256 |
OstTrace1( TRACE_NORMAL, DUP1_CMMPHONETRECEIVER_CONSTRUCTL, "CMmPhoNetReceiver::ConstructL;iMessageBuffer->Length=%d", iMessageBuffer->Length() );
|
|
257 |
TFLOGSTRING3("TSY: iMessageBufferPtr len=%d maxlen=%d",
|
|
258 |
iMessageBufferPtr.Length(),
|
|
259 |
iMessageBufferPtr.MaxLength());
|
|
260 |
OstTrace1( TRACE_NORMAL, DUP2_CMMPHONETRECEIVER_CONSTRUCTL, "CMmPhoNetReceiver::ConstructL;iMessageBufferPtr.MaxLength=%d", iMessageBufferPtr.MaxLength() );
|
|
261 |
}
|
|
262 |
|
|
263 |
// -----------------------------------------------------------------------------
|
|
264 |
// CMmPhoNetReceiver::DoCancel
|
|
265 |
// Cancels an active receiver request.
|
|
266 |
// -----------------------------------------------------------------------------
|
|
267 |
//
|
|
268 |
void CMmPhoNetReceiver::DoCancel()
|
|
269 |
{
|
|
270 |
TFLOGSTRING("TSY: CMmPhoNetReceiver::DoCancel");
|
|
271 |
OstTrace0( TRACE_NORMAL, CMMPHONETRECEIVER_DOCANCEL, "CMmPhoNetReceiver::DoCancel" );
|
|
272 |
// Cancel message receiving from Phonet
|
|
273 |
iPhoNet->ReceiveCancel();
|
|
274 |
}
|
|
275 |
|
|
276 |
// -----------------------------------------------------------------------------
|
|
277 |
// CMmPhoNetReceiver::RunError
|
|
278 |
// Called when RunL leaves.
|
|
279 |
// Calls message handler's HandleError method,
|
|
280 |
// iMessageReceiver variable carries pointer to message handler.
|
|
281 |
// -----------------------------------------------------------------------------
|
|
282 |
//
|
|
283 |
TInt CMmPhoNetReceiver::RunError
|
|
284 |
(
|
|
285 |
TInt aError // Error from RunL or active scheduler
|
|
286 |
)
|
|
287 |
{
|
|
288 |
TFLOGSTRING2("TSY: CMmPhoNetReceiver::RunError - Error code: %d", aError);
|
|
289 |
OstTrace1( TRACE_NORMAL, CMMPHONETRECEIVER_RUNERROR, "CMmPhoNetReceiver::RunError;aError=%d", aError );
|
|
290 |
if ( iMessageReceiver )
|
|
291 |
{
|
|
292 |
iMessageReceiver->HandleError( TIsiReceiveC( iMessageBufferPtr ),
|
|
293 |
aError );
|
|
294 |
iMessageReceiver = NULL;
|
|
295 |
}
|
|
296 |
|
|
297 |
if ( NULL == iMessageBuffer )
|
|
298 |
{
|
|
299 |
TFLOGSTRING("TSY: CMmPhoNetReceiver::RunError\
|
|
300 |
-- receive buffer resize failed!");
|
|
301 |
OstTrace0( TRACE_NORMAL, DUP1_CMMPHONETRECEIVER_RUNERROR, "CMmPhoNetReceiver::RunError, receive buffer resize failed!" );
|
|
302 |
}
|
|
303 |
|
|
304 |
// Restart message receiving
|
|
305 |
TRAPD( result, ReceiveL() );
|
|
306 |
return result;
|
|
307 |
}
|
|
308 |
|
|
309 |
// -----------------------------------------------------------------------------
|
|
310 |
// CMmPhoNetReceiver::RunL
|
|
311 |
// Handles messages received from PhoNet when receiver request
|
|
312 |
// is completed by PhoNet
|
|
313 |
// -----------------------------------------------------------------------------
|
|
314 |
//
|
|
315 |
void CMmPhoNetReceiver::RunL()
|
|
316 |
{
|
|
317 |
TFLOGSTRING3("TSY: CMmPhoNetReceiver::RunL\
|
|
318 |
-- iMessageBufferPtr len=%d maxlen=%d",
|
|
319 |
iMessageBufferPtr.Length(),
|
|
320 |
iMessageBufferPtr.MaxLength());
|
|
321 |
OstTraceExt2( TRACE_NORMAL, CMMPHONETRECEIVER_RUNL, "CMmPhoNetReceiver::RunL;iMessageBufferPtr.Length=%d;iMessageBufferPtr.MaxLength=%d", iMessageBufferPtr.Length(), iMessageBufferPtr.MaxLength() );
|
|
322 |
|
|
323 |
if ( KErrNone != iStatus.Int() && KErrOverflow != iStatus.Int() )
|
|
324 |
{
|
|
325 |
// If message was too large, allocate more memory and re-request
|
|
326 |
// message.
|
|
327 |
if ( KErrNoMemory == iStatus.Int() )
|
|
328 |
{
|
|
329 |
TFLOGSTRING2("TSY: CMmPhoNetReceiver::RunL\
|
|
330 |
-- Large message received, resizing buffer to %d",
|
|
331 |
iNeededBufferLength);
|
|
332 |
OstTraceExt1( TRACE_NORMAL, DUP1_CMMPHONETRECEIVER_RUNL, "CMmPhoNetReceiver::RunL;iNeededBufferLength=%hu", iNeededBufferLength );
|
|
333 |
// Request message again
|
|
334 |
ReceiveL( iNeededBufferLength );
|
|
335 |
}
|
|
336 |
else
|
|
337 |
{
|
|
338 |
// For all other error cases, just start waiting for next message
|
|
339 |
TFLOGSTRING2("CMmPhoNetReceiver::Receive - iStatus = %d",
|
|
340 |
iStatus.Int());
|
|
341 |
OstTrace1( TRACE_NORMAL, DUP2_CMMPHONETRECEIVER_RUNL, "CMmPhoNetReceiver::RunL;iStatus.Int=%d", iStatus.Int() );
|
|
342 |
ReceiveL();
|
|
343 |
}
|
|
344 |
}
|
|
345 |
else
|
|
346 |
{
|
|
347 |
// Print message to log
|
|
348 |
TFLOG_PRINT_ISIMESSAGE( iMessageBufferPtr );
|
|
349 |
|
|
350 |
// Dispatch message to receivers
|
|
351 |
DispatchL( TIsiReceiveC( iMessageBufferPtr ) );
|
|
352 |
|
|
353 |
// Start waiting for next message
|
|
354 |
ReceiveL();
|
|
355 |
}
|
|
356 |
}
|
|
357 |
|
|
358 |
// -----------------------------------------------------------------------------
|
|
359 |
// CMmPhoNetReceiver::RegisterL
|
|
360 |
// Register messagereceiver to phonetreceiver.
|
|
361 |
// -1 can be used as aMessageId to mean all messages for resource
|
|
362 |
// -----------------------------------------------------------------------------
|
|
363 |
//
|
|
364 |
void CMmPhoNetReceiver::RegisterL
|
|
365 |
(
|
|
366 |
MMmMessageReceiver* aReceiver,
|
|
367 |
TInt aResource,
|
|
368 |
TInt aMessageId
|
|
369 |
)
|
|
370 |
{
|
|
371 |
TFLOGSTRING4("TSY: CMmPhoNetReceiver::RegisterL\
|
|
372 |
-- receiver=0x%x resource=0x%x msgid=0x%x",
|
|
373 |
(TInt)aReceiver,
|
|
374 |
aResource,
|
|
375 |
aMessageId);
|
|
376 |
OstTraceExt3( TRACE_NORMAL, CMMPHONETRECEIVER_REGISTERL, "CMmPhoNetReceiver::RegisterL;aReceiver=%x;aResource=%x;aMessageId=%d", (TInt)aReceiver, aResource, aMessageId );
|
|
377 |
|
|
378 |
TInt resourceIndex = -1;
|
|
379 |
|
|
380 |
// Check for double registrations.
|
|
381 |
for ( TInt i = 0; i < iMsgReceivers.Count(); i++ )
|
|
382 |
{
|
|
383 |
const TMessageReceiverInfo& ri = iMsgReceivers[i];
|
|
384 |
|
|
385 |
if ( ri.iResource == aResource )
|
|
386 |
{
|
|
387 |
// Store index where new registration entry is later to be stored
|
|
388 |
resourceIndex = i;
|
|
389 |
|
|
390 |
if ( ( ri.iReceiver == aReceiver ) &&
|
|
391 |
( ri.iMessageId == aMessageId ||
|
|
392 |
-1 == ri.iMessageId ||
|
|
393 |
-1 == aMessageId ) )
|
|
394 |
{
|
|
395 |
// We want to avoid situations where the same handler receivers
|
|
396 |
// a message twice..
|
|
397 |
TFLOGSTRING("TSY: CMmPhoNetReceiver::RegisterL\
|
|
398 |
-- Already registered");
|
|
399 |
OstTrace0( TRACE_NORMAL, DUP1_CMMPHONETRECEIVER_REGISTERL, "CMmPhoNetReceiver::RegisterL, ASSERT Already registered" );
|
|
400 |
TF_ASSERT_NOT_REACHED();
|
|
401 |
return;
|
|
402 |
}
|
|
403 |
}
|
|
404 |
}
|
|
405 |
|
|
406 |
// Register
|
|
407 |
TMessageReceiverInfo info;
|
|
408 |
info.iReceiver = aReceiver;
|
|
409 |
info.iResource = aResource;
|
|
410 |
info.iMessageId = aMessageId;
|
|
411 |
|
|
412 |
// Because of binary search in DispatchL method we have to keep objects in
|
|
413 |
// the order. For example all PN_CALL requests are located in sequential
|
|
414 |
// locations.
|
|
415 |
if ( -1 == resourceIndex )
|
|
416 |
{
|
|
417 |
// This is registration for a new server
|
|
418 |
TInt i = iMsgReceivers.Count();
|
|
419 |
|
|
420 |
for ( ; i > 0; i-- )
|
|
421 |
{
|
|
422 |
const TMessageReceiverInfo& ri = iMsgReceivers[i-1];
|
|
423 |
if ( ri.iResource < aResource )
|
|
424 |
{
|
|
425 |
resourceIndex = i;
|
|
426 |
break;
|
|
427 |
}
|
|
428 |
}
|
|
429 |
|
|
430 |
if ( -1 == resourceIndex )
|
|
431 |
{
|
|
432 |
// Insert new registration at the start of array
|
|
433 |
resourceIndex = 0;
|
|
434 |
}
|
|
435 |
}
|
|
436 |
|
|
437 |
iMsgReceivers.InsertL( info, resourceIndex );
|
|
438 |
}
|
|
439 |
|
|
440 |
// -----------------------------------------------------------------------------
|
|
441 |
// CMmPhoNetReceiver::DispatchL
|
|
442 |
// Get received message from phonet and dispatch it
|
|
443 |
// to all registered receivers. Cache SAT messages if SAT is not yet initialized
|
|
444 |
// Binary search is used to find first message handler registered to receive
|
|
445 |
// the message.
|
|
446 |
// -----------------------------------------------------------------------------
|
|
447 |
//
|
|
448 |
void CMmPhoNetReceiver::DispatchL
|
|
449 |
(
|
|
450 |
const TIsiReceiveC& aIsiMessage
|
|
451 |
)
|
|
452 |
{
|
|
453 |
TFLOGSTRING("TSY: CMmPhoNetReceiver::DispatchL");
|
|
454 |
OstTrace0( TRACE_NORMAL, CMMPHONETRECEIVER_DISPATCHL, "CMmPhoNetReceiver::DispatchL" );
|
|
455 |
|
|
456 |
// Get resource and message id
|
|
457 |
TInt resource( aIsiMessage.Get8bit( ISI_HEADER_OFFSET_RESOURCEID ) );
|
|
458 |
TInt messageId( aIsiMessage.Get8bit( ISI_HEADER_OFFSET_MESSAGEID ) );
|
|
459 |
|
|
460 |
TFLOGSTRING3("TSY: CMmPhoNetReceiver::DispatchL - resource: 0x%x, id: 0x%x",
|
|
461 |
resource,
|
|
462 |
messageId);
|
|
463 |
OstTraceExt2( TRACE_NORMAL, DUP1_CMMPHONETRECEIVER_DISPATCHL, "CMmPhoNetReceiver::DispatchL;resource=%d;messageId=%x", resource, messageId );
|
|
464 |
|
|
465 |
// Get lowest request index using binary search
|
|
466 |
TInt highIndex = iMsgReceivers.Count();
|
|
467 |
TInt lowIndex = -1;
|
|
468 |
TInt probe;
|
|
469 |
while ( highIndex - lowIndex > 1 )
|
|
470 |
{
|
|
471 |
probe = ( highIndex + lowIndex ) / 2;
|
|
472 |
const TMessageReceiverInfo& ri = iMsgReceivers[probe];
|
|
473 |
if ( ri.iResource < resource )
|
|
474 |
{
|
|
475 |
lowIndex = probe;
|
|
476 |
}
|
|
477 |
else
|
|
478 |
{
|
|
479 |
highIndex = probe;
|
|
480 |
}
|
|
481 |
}
|
|
482 |
|
|
483 |
// Send ISI message to message handlers
|
|
484 |
for ( ; highIndex < iMsgReceivers.Count(); highIndex++ )
|
|
485 |
{
|
|
486 |
const TMessageReceiverInfo& recInfo = iMsgReceivers[highIndex];
|
|
487 |
if ( recInfo.iResource == resource )
|
|
488 |
{
|
|
489 |
if ( recInfo.iMessageId == messageId || -1 == recInfo.iMessageId )
|
|
490 |
{
|
|
491 |
iMessageReceiver = recInfo.iReceiver;
|
|
492 |
iMessageReceiver->ReceiveMessageL( aIsiMessage );
|
|
493 |
}
|
|
494 |
}
|
|
495 |
else
|
|
496 |
{
|
|
497 |
// Stop searching
|
|
498 |
break;
|
|
499 |
}
|
|
500 |
}
|
|
501 |
|
|
502 |
// Should be set null here in case SAT receivemessage leaves
|
|
503 |
iMessageReceiver = NULL;
|
|
504 |
|
|
505 |
if( iSatMessHandler )
|
|
506 |
{
|
|
507 |
// Sat message handler takes all messages. So make it fast.
|
|
508 |
iSatMessHandler->ReceiveMessageL( aIsiMessage );
|
|
509 |
}
|
|
510 |
}
|
|
511 |
|
|
512 |
// -----------------------------------------------------------------------------
|
|
513 |
// CMmPhoNetReceiver::Receive
|
|
514 |
// Start waiting for message from Phonet.
|
|
515 |
// -----------------------------------------------------------------------------
|
|
516 |
//
|
|
517 |
void CMmPhoNetReceiver::ReceiveL
|
|
518 |
(
|
|
519 |
TInt aBufferLength
|
|
520 |
)
|
|
521 |
{
|
|
522 |
TFLOGSTRING("TSY: CMmPhoNetReceiver::Receive");
|
|
523 |
OstTrace0( TRACE_NORMAL, CMMPHONETRECEIVER_RECEIVEL, "CMmPhoNetReceiver::ReceiveL" );
|
|
524 |
|
|
525 |
// Resize receive buffer size if necessary
|
|
526 |
if ( NULL == iMessageBuffer ||
|
|
527 |
aBufferLength != iMessageBufferPtr.MaxLength() )
|
|
528 |
{
|
|
529 |
TFLOGSTRING2("TSY: CMmPhoNetReceiver::Receive - resizing buffer to %d",
|
|
530 |
aBufferLength);
|
|
531 |
OstTrace1( TRACE_NORMAL, DUP1_CMMPHONETRECEIVER_RECEIVEL, "CMmPhoNetReceiver::ReceiveL;aBufferLength=%d", aBufferLength );
|
|
532 |
|
|
533 |
// Delete old buffer
|
|
534 |
delete iMessageBuffer;
|
|
535 |
iMessageBuffer = NULL;
|
|
536 |
|
|
537 |
// Allocate new buffer
|
|
538 |
iMessageBuffer = HBufC8::NewL( aBufferLength );
|
|
539 |
iMessageBufferPtr.Set( iMessageBuffer->Des() );
|
|
540 |
TFLOGSTRING2("TSY: iMessageBuffer len=%d", iMessageBuffer->Length());
|
|
541 |
OstTrace1( TRACE_NORMAL, DUP2_CMMPHONETRECEIVER_RECEIVEL, "CMmPhoNetReceiver::ReceiveL;iMessageBuffer->Length=%d", iMessageBuffer->Length() );
|
|
542 |
}
|
|
543 |
|
|
544 |
// Do asyncronous reqest for message from Phonet
|
|
545 |
iMessageBufferPtr.SetLength( 0 );
|
|
546 |
iStatus = KRequestPending;
|
|
547 |
iPhoNet->Receive( iStatus, iMessageBufferPtr, iNeededBufferLength );
|
|
548 |
// Indicate that the active object has issued a
|
|
549 |
// request and that it is now outstanding.
|
|
550 |
SetActive();
|
|
551 |
}
|
|
552 |
|
|
553 |
// -----------------------------------------------------------------------------
|
|
554 |
// CMmPhoNetReceiver::SetSatMessHandler
|
|
555 |
// Set SAT messagehandler pointer, called by SIM_ATK_TSY
|
|
556 |
// -----------------------------------------------------------------------------
|
|
557 |
//
|
|
558 |
TInt CMmPhoNetReceiver::SetSatMessHandler
|
|
559 |
(
|
|
560 |
MMmMessageReceiver* aSatMessHandler // SAT messagehandler
|
|
561 |
)
|
|
562 |
{
|
|
563 |
TFLOGSTRING("TSY: CMmPhoNetReceiver::SetSatMessHandler");
|
|
564 |
OstTrace0( TRACE_NORMAL, CMMPHONETRECEIVER_SETSATMESSHANDLER, "CMmPhoNetReceiver::SetSatMessHandler" );
|
|
565 |
iSatMessHandler = aSatMessHandler;
|
|
566 |
return KErrNone;
|
|
567 |
}
|
|
568 |
|
|
569 |
// -----------------------------------------------------------------------------
|
|
570 |
// CMmPhoNetReceiver::SatReady
|
|
571 |
// SIM_ATK_TSY requests cached SAT message from NokiaTSY by calling this method
|
|
572 |
// -----------------------------------------------------------------------------
|
|
573 |
//
|
|
574 |
TInt CMmPhoNetReceiver::SatReady
|
|
575 |
(
|
|
576 |
TUint8 aTypeOfCommandRequested // Message Id
|
|
577 |
)
|
|
578 |
{
|
|
579 |
TFLOGSTRING("TSY: CMmPhoNetReceiver::SatReady");
|
|
580 |
OstTrace0( TRACE_NORMAL, CMMPHONETRECEIVER_SATREADY, "CMmPhoNetReceiver::SatReady" );
|
|
581 |
TInt ret( KErrNotFound );
|
|
582 |
|
|
583 |
// If there is cached SAT message that
|
|
584 |
// matches request type return it to SIM_ATK_TSY
|
|
585 |
if ( iSatMessageBuffer )
|
|
586 |
{
|
|
587 |
const TDesC8& message( *iSatMessageBuffer );
|
|
588 |
|
|
589 |
// Take typeofcommand from TLV
|
|
590 |
TUint8 typeOfCommand = ( 0x81 == message[15] ) ? message[20] : message[19];
|
|
591 |
|
|
592 |
TFLOGSTRING3("TSY: CMmPhoNetReceiver::SatReady\
|
|
593 |
-- aTypeOfCommandRequested: 0x%x, typeOfCommand: 0x%x",
|
|
594 |
aTypeOfCommandRequested,
|
|
595 |
typeOfCommand);
|
|
596 |
OstTraceExt2( TRACE_NORMAL, DUP1_CMMPHONETRECEIVER_SATREADY, "CMmPhoNetReceiver::SatReady;aTypeOfCommandRequested=%hhx;typeOfCommand=%hhx", aTypeOfCommandRequested, typeOfCommand );
|
|
597 |
|
|
598 |
if ( typeOfCommand == aTypeOfCommandRequested )
|
|
599 |
{
|
|
600 |
TFLOGSTRING("TSY: CMmPhoNetReceiver::SatReady -- sending msg to sat");
|
|
601 |
OstTrace0( TRACE_NORMAL, DUP2_CMMPHONETRECEIVER_SATREADY, "CMmPhoNetReceiver::SatReady, sending msg to sat" );
|
|
602 |
// Call receivemessage and catch possible leave.
|
|
603 |
TRAP_IGNORE( iSatMessHandler->ReceiveMessageL(
|
|
604 |
TIsiReceiveC( message ) ) );
|
|
605 |
// Free used buffer
|
|
606 |
delete iSatMessageBuffer;
|
|
607 |
iSatMessageBuffer = NULL;
|
|
608 |
TFLOGSTRING("TSY: CMmPhoNetReceiver::SatReady\
|
|
609 |
-- iSatMessageBuffer deleted");
|
|
610 |
OstTrace0( TRACE_NORMAL, DUP3_CMMPHONETRECEIVER_SATREADY, "CMmPhoNetReceiver::SatReady, iSatMessageBuffer deleted" );
|
|
611 |
ret = KErrNone;
|
|
612 |
}
|
|
613 |
}
|
|
614 |
return ret;
|
|
615 |
}
|
|
616 |
|
|
617 |
// ==================== OTHER EXPORTED FUNCTIONS ===============================
|
|
618 |
// None
|
|
619 |
|
|
620 |
// End of File
|