20 #include <iscapi.h> //For ISC |
20 #include <iscapi.h> //For ISC |
21 #include <iscnokiadefinitions.h> //isc definitions |
21 #include <iscnokiadefinitions.h> //isc definitions |
22 #include <pn_const.h> |
22 #include <pn_const.h> |
23 #ifndef NCP_COMMON_BRIDGE_FAMILY |
23 #ifndef NCP_COMMON_BRIDGE_FAMILY |
24 #include <nsisi.h> |
24 #include <nsisi.h> |
|
25 #include <pipeisi.h> //pipe |
|
26 #include <pipe_sharedisi.h> //pipe |
25 #endif |
27 #endif |
26 #include <tisi.h> //for isimessage |
28 #include <tisi.h> //for isimessage |
27 #include <pipeisi.h> //pipe |
|
28 #include <pipe_sharedisi.h> //pipe |
|
29 #include "cmodematpipecontroller.h" |
29 #include "cmodematpipecontroller.h" |
30 #include "cmodemathandler.h" |
30 #include "cmodemathandler.h" |
31 #include <at_modemisi.h> //redirectreq error codes |
31 #include <at_modemisi.h> //redirectreq error codes |
32 #include "modemattrace.h" |
32 #include "modemattrace.h" |
33 #include "cmodematsrv.h" |
33 #include "cmodematsrv.h" |
34 |
34 |
35 const TInt KInvalidPipeHandle = -1; |
35 |
36 #ifndef NCP_COMMON_BRIDGE_FAMILY |
36 #ifndef NCP_COMMON_BRIDGE_FAMILY |
37 const TUint8 PEP_COMM_IND_ID_ESCAPE(0x07); |
37 const TUint8 PEP_COMM_IND_ID_ESCAPE = 0x07; |
38 const TInt KInvalidDteId = -1; |
|
39 const TUint8 KFiller = 0; |
38 const TUint8 KFiller = 0; |
40 const TUint8 KDefaultTrId(0); |
39 const TUint8 KDefaultTrId = 0; |
|
40 const TInt KLastByteIndex = 3; |
41 #endif |
41 #endif |
42 const TInt KLastByteIndex = 3; |
|
43 |
42 |
44 CModemAtPipeController* CModemAtPipeController::NewL( RIscApi& aIscApi, |
43 CModemAtPipeController* CModemAtPipeController::NewL( RIscApi& aIscApi, |
45 TUint& aObjId, |
44 TUint& aObjId, |
46 CModemAtHandler& aHandler ) |
45 CModemAtHandler& aHandler ) |
47 { |
46 { |
74 TUint& aObjId, |
73 TUint& aObjId, |
75 CModemAtHandler& aHandler ) : |
74 CModemAtHandler& aHandler ) : |
76 iIscApi( aIscApi ), |
75 iIscApi( aIscApi ), |
77 iModemAtObjId( aObjId ), |
76 iModemAtObjId( aObjId ), |
78 iModemAtDevId( THIS_DEVICE ), |
77 iModemAtDevId( THIS_DEVICE ), |
79 iPipeHandle( KInvalidPipeHandle ), |
|
80 iDataportDevId( 0 ), |
78 iDataportDevId( 0 ), |
81 iDataportObjId( 0 ), |
79 iDataportObjId( 0 ), |
82 iAtHandler( aHandler ), |
80 iAtHandler( aHandler ), |
83 iSchedulerWait( NULL ), |
81 iSchedulerWait( NULL ) |
84 iDteId( KInitialDteId ) |
82 { |
85 { |
83 C_TRACE (( _T("CModemAtPipeController::CModemAtPipeController()>") )); |
86 C_TRACE (( _T("CModemAtPipeController::CModemAtPipeController()") )); |
84 iPipe.pipeHandle = KInvalidPipeHandle; |
|
85 iPipe.firstDevId = 0; |
|
86 iPipe.firstObjId = 0; |
|
87 iPipe.secondDevId = 0; |
|
88 iPipe.secondDevId = 0; |
|
89 iPipe.pipeState = TPipeInfo::EPipeNoPipe; |
|
90 |
|
91 C_TRACE (( _T("CModemAtPipeController::CModemAtPipeController()<") )); |
87 } |
92 } |
88 |
93 |
89 |
94 |
90 #ifndef NCP_COMMON_BRIDGE_FAMILY |
95 #ifndef NCP_COMMON_BRIDGE_FAMILY |
91 void CModemAtPipeController::HandleNameServiceMessage( const TIsiReceiveC& aReceivedMessage ) |
96 void CModemAtPipeController::HandleNameServiceMessage( const TIsiReceiveC& aReceivedMessage ) |
210 PN_NAME_SRV_ITEM_STR_OFFSET_DEV ); |
215 PN_NAME_SRV_ITEM_STR_OFFSET_DEV ); |
211 iDataportObjId = aReceivedMessage.Get8bit( ISI_HEADER_SIZE + |
216 iDataportObjId = aReceivedMessage.Get8bit( ISI_HEADER_SIZE + |
212 PNS_NAME_ADD_IND_OFFSET_NAMEENTRYTBL * i + |
217 PNS_NAME_ADD_IND_OFFSET_NAMEENTRYTBL * i + |
213 PN_NAME_SRV_ITEM_STR_OFFSET_OBJ); |
218 PN_NAME_SRV_ITEM_STR_OFFSET_OBJ); |
214 |
219 |
215 if( iDataportDevId == THIS_DEVICE ) |
220 if( ( iDataportDevId == THIS_DEVICE ) && |
|
221 ( iPipe.pipeState == TPipeInfo::EPipeNoPipe ) ) |
216 { |
222 { |
217 C_TRACE((_L("CREATE PIPE FROM DATAPORT when ATEXT plugins connect (devid %x o-bjid %x) "),iDataportDevId,iDataportObjId)); |
223 C_TRACE((_L("Creating pipe. (Dataport device id 0x%x, object id: 0x%x)"),iDataportDevId,iDataportObjId)); |
|
224 SendCreatePipeMessage( iDataportDevId, iDataportObjId ); |
218 } |
225 } |
219 else |
226 else |
220 { |
227 { |
221 C_TRACE((_L("ERROR: PIPE not Created due to unmatching DevId: 0x%x or ObjId 0x%x"),iDataportDevId, iDataportObjId )); |
228 C_TRACE((_L("ERROR: Pipe is not created. (Dataport device id 0x%x, object id: 0x%x)"),iDataportDevId, iDataportObjId )); |
222 TRACE_ASSERT_ALWAYS; |
229 TRACE_ASSERT_ALWAYS; |
223 } |
230 } |
224 } |
231 } |
225 } |
232 } |
226 } |
233 } |
328 |
335 |
329 |
336 |
330 void CModemAtPipeController::HandlePipeCreateResp( const TIsiReceiveC& aReceivedMessage ) |
337 void CModemAtPipeController::HandlePipeCreateResp( const TIsiReceiveC& aReceivedMessage ) |
331 { |
338 { |
332 C_TRACE (( _T("CModemAtPipeController::HandlePipeCreateResp()") )); |
339 C_TRACE (( _T("CModemAtPipeController::HandlePipeCreateResp()") )); |
333 TInt error = aReceivedMessage.Get8bit(ISI_HEADER_SIZE + PNS_PIPE_CREATE_RESP_OFFSET_ERRORCODE ); |
340 TInt error = aReceivedMessage.Get8bit(ISI_HEADER_SIZE + |
|
341 PNS_PIPE_CREATE_RESP_OFFSET_ERRORCODE ); |
334 C_TRACE((_L("Pipe create resp: %d"), error )); |
342 C_TRACE((_L("Pipe create resp: %d"), error )); |
335 TRACE_ASSERT( iDteId != KInitialDteId ); |
343 |
336 |
|
337 if( error == PN_PIPE_NO_ERROR) |
344 if( error == PN_PIPE_NO_ERROR) |
338 { |
345 { |
339 iPipeHandle = aReceivedMessage.Get8bit( ISI_HEADER_SIZE + |
346 iPipe.pipeHandle = aReceivedMessage.Get8bit( ISI_HEADER_SIZE + |
340 PNS_PIPE_CREATE_RESP_OFFSET_PIPEHANDLE ); |
347 PNS_PIPE_CREATE_RESP_OFFSET_PIPEHANDLE ); |
341 C_TRACE( (_L("handle %d"), iPipeHandle )); |
348 C_TRACE( (_L("Pipe created successfully. Pipehandle: %d"), iPipe.pipeHandle )); |
342 iPipeTable[iDteId].iHandle = iPipeHandle; |
349 |
343 iPipeTable[iDteId].iFirstDevId = iDataportDevId; |
350 // Now that pipehandle is received, it will also be used as dteId when connecting to AT Modem. |
344 iPipeTable[iDteId].iFirstObjId = iDataportObjId; |
351 |
345 iPipeTable[iDteId].iSecondDevId = THIS_DEVICE; |
352 iPipe.firstDevId = iDataportDevId; |
346 iPipeTable[iDteId].iSecondObjId = iModemAtObjId; |
353 iPipe.firstObjId = iDataportObjId; |
347 ChangePipeState( iDteId, TPipeInfo::EPipeCreated ); |
354 iPipe.secondDevId = THIS_DEVICE; |
348 iPipeHandle = KInvalidPipeHandle; |
355 iPipe.secondObjId = iModemAtObjId; |
349 iDteId = KInitialDteId; |
356 ChangePipeState( TPipeInfo::EPipeCreated ); |
|
357 |
350 } |
358 } |
351 else |
359 else |
352 { |
360 { |
353 C_TRACE (( _T("iPipeHandle == KInvalidPipeHandle "))); |
361 C_TRACE((_L("Pipe creation failed: %d"), error )); |
354 iPipeTable[iDteId].iHandle = KInvalidPipeHandle; |
362 iPipe.pipeHandle = KInvalidPipeHandle; |
355 iPipeTable[iDteId].iFirstDevId = 0; |
363 iPipe.firstDevId = 0; |
356 iPipeTable[iDteId].iFirstObjId = 0; |
364 iPipe.firstObjId = 0; |
357 iPipeTable[iDteId].iSecondDevId = 0; |
365 iPipe.secondDevId = 0; |
358 iPipeTable[iDteId].iSecondObjId = 0; |
366 iPipe.secondObjId = 0; |
359 ChangePipeState( iDteId, TPipeInfo::EPipeNoPipe ); |
367 ChangePipeState( TPipeInfo::EPipeNoPipe ); |
360 ASSERT_ALWAYS; |
368 ASSERT_ALWAYS; |
361 } |
369 } |
362 } |
370 } |
363 |
371 |
364 void CModemAtPipeController::LinkDteIdToPipe( const TUint8 aDteId ) |
|
365 { |
|
366 C_TRACE (( _T("CModemAtPipeController::LinkDteIdToPipe(0x%x)"), aDteId )); |
|
367 TRACE_ASSERT( aDteId < KMaxDteIdCount ); |
|
368 if( !(aDteId < KMaxDteIdCount) ) |
|
369 { |
|
370 C_TRACE(( _T("CModemAtPipeController::LinkDteIdToPipe() illegal dteid %d"), aDteId )); |
|
371 return; |
|
372 } |
|
373 |
|
374 iDteId = aDteId; |
|
375 if( iDataportDevId == THIS_DEVICE ) |
|
376 { |
|
377 C_TRACE((_L("CREATE PIPE FROM DATAPORT (plugins are connecting) (devid %x o-bjid %x) "),iDataportDevId,iDataportObjId)); |
|
378 SendCreatePipeMessage( iDataportDevId, iDataportObjId ); |
|
379 } |
|
380 else |
|
381 { |
|
382 C_TRACE((_L("Dataport has not been created (devid %x o-bjid %x) "), iDataportDevId, iDataportObjId )); |
|
383 C_TRACE (( _T("iPipeHandle == KInvalidPipeHandle "))); |
|
384 iPipeTable[aDteId].iHandle = KInvalidPipeHandle; |
|
385 iPipeTable[aDteId].iFirstDevId = 0; |
|
386 iPipeTable[aDteId].iFirstObjId = 0; |
|
387 iPipeTable[aDteId].iSecondDevId = 0; |
|
388 iPipeTable[aDteId].iSecondObjId = 0; |
|
389 ChangePipeState( aDteId, TPipeInfo::EPipeNoPipe ); |
|
390 } |
|
391 } |
|
392 |
372 |
393 |
373 |
394 void CModemAtPipeController::HandlePipeRemoveResp( const TIsiReceiveC& aReceivedMessage ) |
374 void CModemAtPipeController::HandlePipeRemoveResp( const TIsiReceiveC& aReceivedMessage ) |
395 { |
375 { |
396 C_TRACE (( _T(">>CModemAtPipeController::HandlePipeRemoveResp()") )); |
376 C_TRACE (( _T(">>CModemAtPipeController::HandlePipeRemoveResp()") )); |
397 TInt error = aReceivedMessage.Get8bit( ISI_HEADER_SIZE + |
377 TInt error = aReceivedMessage.Get8bit( ISI_HEADER_SIZE + |
398 PNS_PIPE_REMOVE_RESP_OFFSET_ERRORCODE ); |
378 PNS_PIPE_REMOVE_RESP_OFFSET_ERRORCODE ); |
399 TInt pipehandle = aReceivedMessage.Get8bit( ISI_HEADER_SIZE + |
379 TInt pipehandle = aReceivedMessage.Get8bit( ISI_HEADER_SIZE + |
400 PNS_PIPE_REMOVE_RESP_OFFSET_PIPEHANDLE ); |
380 PNS_PIPE_REMOVE_RESP_OFFSET_PIPEHANDLE ); |
401 |
381 |
402 TInt dteId = FindDteId( pipehandle ); |
382 TRACE_ASSERT( pipehandle == iPipe.pipeHandle ); |
403 |
383 if( pipehandle != iPipe.pipeHandle ) |
404 TRACE_ASSERT( dteId < KMaxDteIdCount ) |
384 { |
405 if( !(dteId < KMaxDteIdCount) ) |
385 C_TRACE(( _T("CModemAtPipeController::HandlePipeRemoveResp() illegal pipehandle %d"), pipehandle )); |
406 { |
|
407 C_TRACE(( _T("CModemAtPipeController::HandlePipeRemoveResp() illegal dteid %d"), dteId )); |
|
408 return; |
386 return; |
409 } |
387 } |
410 |
388 |
411 TRACE_ASSERT( error == PN_PIPE_NO_ERROR ) |
389 TRACE_ASSERT( error == PN_PIPE_NO_ERROR ) |
412 if( error != PN_PIPE_NO_ERROR ) |
390 if( error != PN_PIPE_NO_ERROR ) |
413 { |
391 { |
414 C_TRACE(( _T("CModemAtPipeController::HandlePipeRemoveResp() error %d"), error )); |
392 C_TRACE(( _T("CModemAtPipeController::HandlePipeRemoveResp() error %d"), error )); |
415 return; |
393 return; |
416 } |
394 } |
417 |
395 |
418 ChangePipeState( dteId, TPipeInfo::EPipeNoPipe ); |
396 ChangePipeState( TPipeInfo::EPipeNoPipe ); |
419 |
397 |
420 iPipeTable[ dteId ].iHandle = KInvalidPipeHandle; |
398 iPipe.pipeHandle = KInvalidPipeHandle; |
421 |
399 |
422 if( iSchedulerWait ) |
400 if( iSchedulerWait ) |
423 { |
401 { |
424 C_TRACE((_L("CModemAtPipeController::HandlePipeRemoveResp() iSchedulerWait->Stop"))); |
402 C_TRACE((_L("CModemAtPipeController::HandlePipeRemoveResp() iSchedulerWait->Stop"))); |
425 iSchedulerWait->AsyncStop(); |
403 iSchedulerWait->AsyncStop(); |
432 |
410 |
433 void CModemAtPipeController::RemovePipe( const TUint8 aDteId ) |
411 void CModemAtPipeController::RemovePipe( const TUint8 aDteId ) |
434 { |
412 { |
435 C_TRACE (( _T("CModemAtPipeController::RemovePipe(%d, 0x%x)"), aDteId, this )); |
413 C_TRACE (( _T("CModemAtPipeController::RemovePipe(%d, 0x%x)"), aDteId, this )); |
436 |
414 |
437 TRACE_ASSERT( aDteId < KMaxDteIdCount ); |
415 C_TRACE (( _T("iPipe:0x%x"), &iPipe )); |
438 if( !(aDteId < KMaxDteIdCount) ) |
416 C_TRACE (( _T("iHandle: %d"), iPipe.pipeHandle )); |
439 { |
417 C_TRACE (( _T("i1stDevId: %d"), iPipe.firstDevId )); |
440 C_TRACE(( _T("CModemAtPipeController::RemovePipe() illegal dteid %d"), aDteId )); |
418 C_TRACE (( _T("i1stObjId: %d"), iPipe.firstObjId )); |
441 return; |
419 C_TRACE (( _T("i2ndDevId: %d"), iPipe.secondDevId )); |
442 } |
420 C_TRACE (( _T("i2ndObjId: %d"), iPipe.secondObjId )); |
443 |
|
444 C_TRACE (( _T("iPipeTable[aDteId]:0x%x"), &iPipeTable[aDteId] )); |
|
445 C_TRACE (( _T("iHandle: %d"), iPipeTable[aDteId].iHandle )); |
|
446 C_TRACE (( _T("i1stDevId: %d"), iPipeTable[aDteId].iFirstDevId )); |
|
447 C_TRACE (( _T("i1stObjId: %d"), iPipeTable[aDteId].iFirstObjId )); |
|
448 C_TRACE (( _T("i2ndDevId: %d"), iPipeTable[aDteId].iSecondDevId )); |
|
449 C_TRACE (( _T("i2ndObjId: %d"), iPipeTable[aDteId].iSecondObjId )); |
|
450 |
421 |
451 if( iPipeTable[aDteId].iHandle != KInvalidPipeHandle ) |
422 if( iPipe.pipeHandle != KInvalidPipeHandle ) |
452 { |
423 { |
453 if( ( iPipeTable[aDteId].iPipeState == TPipeInfo::EPipeRemoving ) || |
424 if( ( iPipe.pipeState == TPipeInfo::EPipeRemoving ) || |
454 ( iPipeTable[aDteId].iPipeState == TPipeInfo::EPipeNoPipe ) ) |
425 ( iPipe.pipeState == TPipeInfo::EPipeNoPipe ) ) |
455 { |
426 { |
456 C_TRACE((_L("Already removing pipe or pipe is removed. Handle %d"), iPipeTable[aDteId].iHandle)); |
427 C_TRACE((_L("Already removing pipe or pipe is removed. Handle %d"), iPipe.pipeHandle)); |
457 return; |
428 return; |
458 } |
429 } |
459 C_TRACE((_L("Remove pipe. Handle %d"), iPipeTable[aDteId].iHandle)); |
430 |
460 ChangePipeState( aDteId, TPipeInfo::EPipeRemoving ); |
431 if( aDteId != iPipe.pipeHandle ) |
461 SendRemovePipeReq( iPipeTable[aDteId].iHandle ); |
432 { |
|
433 C_TRACE(( _T("Dteid %d is not same as pipehandle %d, so there is no pipe to remove."), aDteId, iPipe.pipeHandle )); |
|
434 return; |
|
435 } |
|
436 |
|
437 C_TRACE((_L("Remove pipe. Handle %d"), iPipe.pipeHandle)); |
|
438 ChangePipeState( TPipeInfo::EPipeRemoving ); |
|
439 SendRemovePipeReq( iPipe.pipeHandle ); |
462 } |
440 } |
463 else |
441 else |
464 { |
442 { |
465 C_TRACE((_L("No Pipe to Remove"))); |
443 C_TRACE((_L("No Pipe to Remove"))); |
466 } |
444 } |
502 |
480 |
503 void CModemAtPipeController::RedirectPipe( const TUint8 aDteId, |
481 void CModemAtPipeController::RedirectPipe( const TUint8 aDteId, |
504 const TUint8 aNewDevId, |
482 const TUint8 aNewDevId, |
505 const TUint8 aNewObjId ) |
483 const TUint8 aNewObjId ) |
506 { |
484 { |
507 C_TRACE (( _T("CModemAtPipeController::RedirectPipe() dteid %d"), aDteId )); |
485 C_TRACE (( _T("CModemAtPipeController::RedirectPipe() dteid %d, iPipe.pipeHandle: %d"), aDteId, iPipe.pipeHandle )); |
508 C_TRACE((_L("CModemAtPipeController::RedirectPipe() New pep, deviceId: 0x%x objId: 0x%x "), aNewDevId, aNewObjId)); |
486 C_TRACE((_L("CModemAtPipeController::RedirectPipe() New pep, deviceId: 0x%x objId: 0x%x "), aNewDevId, aNewObjId)); |
509 TRACE_ASSERT( aDteId < KMaxDteIdCount ); |
487 TRACE_ASSERT( aDteId == iPipe.pipeHandle ); |
510 if( !(aDteId < KMaxDteIdCount) ) |
488 if( aDteId != iPipe.pipeHandle ) |
511 { |
489 { |
512 C_TRACE(( _T("CModemAtPipeController::RedirectPipe() illegal dteid %d"), aDteId )); |
490 C_TRACE(( _T("CModemAtPipeController::RedirectPipe() illegal dteid %d"), aDteId )); |
513 return; |
491 return; |
514 } |
492 } |
515 TRACE_ASSERT( iPipeTable[aDteId].iHandle != KInvalidPipeHandle ); |
493 TRACE_ASSERT( iPipe.pipeHandle != KInvalidPipeHandle ); |
516 if( iPipeTable[aDteId].iHandle == KInvalidPipeHandle ) |
494 if( iPipe.pipeHandle == KInvalidPipeHandle ) |
517 { |
495 { |
518 C_TRACE(( _T("CModemAtPipeController::RedirectPipe() invalid pipe handle %d"), iPipeTable[aDteId].iHandle )); |
496 C_TRACE(( _T("CModemAtPipeController::RedirectPipe() invalid pipe handle %d"), iPipe.pipeHandle )); |
519 return; |
497 return; |
520 } |
498 } |
521 |
499 |
522 if( iPipeTable[aDteId].iPipeState == TPipeInfo::EPipeRemoving || |
500 if( iPipe.pipeState == TPipeInfo::EPipeRemoving || |
523 iPipeTable[aDteId].iPipeState == TPipeInfo::EPipeNoPipe ) |
501 iPipe.pipeState == TPipeInfo::EPipeNoPipe ) |
524 { |
502 { |
525 C_TRACE(_L("CModemAtPipeController::RedirectPipe() Pipe is already removed -> cant redirect")); |
503 C_TRACE(_L("CModemAtPipeController::RedirectPipe() Pipe is already removed -> cant redirect")); |
526 return; |
504 return; |
527 } |
505 } |
528 |
506 |
529 if( aNewDevId == THIS_DEVICE && aNewObjId == iModemAtObjId ) |
507 if( aNewDevId == THIS_DEVICE && aNewObjId == iModemAtObjId ) |
530 { |
508 { |
531 C_TRACE((_L("CModemAtPipeController::RedirectPipe() EPipeDisabled. iModemAtObjId: 0x%x"), iModemAtObjId)); |
509 C_TRACE((_L("CModemAtPipeController::RedirectPipe() EPipeDisabled. iModemAtObjId: 0x%x"), iModemAtObjId)); |
532 ChangePipeState( aDteId, TPipeInfo::EPipeDisabled ); |
510 ChangePipeState( TPipeInfo::EPipeDisabled ); |
533 } |
511 } |
534 else |
512 else |
535 { |
513 { |
536 C_TRACE(_L("CModemAtPipeController::RedirectPipe() EPipeRedirected")); |
514 C_TRACE(_L("CModemAtPipeController::RedirectPipe() EPipeRedirected")); |
537 ChangePipeState( aDteId, TPipeInfo::EPipeRedirected ); |
515 ChangePipeState( TPipeInfo::EPipeRedirected ); |
538 } |
516 } |
539 |
517 |
540 C_TRACE(_L("CModemAtPipeController::RedirectPipe() Redirecting pipe")); |
518 C_TRACE(_L("CModemAtPipeController::RedirectPipe() Redirecting pipe")); |
541 |
519 |
542 HBufC8* message = HBufC8::New( ISI_HEADER_SIZE + SIZE_PNS_PIPE_REDIRECT_REQ ); |
520 HBufC8* message = HBufC8::New( ISI_HEADER_SIZE + SIZE_PNS_PIPE_REDIRECT_REQ ); |
547 isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_UTID, 0); |
525 isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_UTID, 0); |
548 |
526 |
549 isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_SUBFUNCTION, |
527 isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_SUBFUNCTION, |
550 PNS_PIPE_REDIRECT_REQ ); |
528 PNS_PIPE_REDIRECT_REQ ); |
551 isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_PIPEHANDLE, |
529 isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_PIPEHANDLE, |
552 iPipeTable[aDteId].iHandle ); |
530 iPipe.pipeHandle ); |
553 isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_STATEAFTERCREATION, |
531 isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_STATEAFTERCREATION, |
554 PN_PIPE_DISABLE ); |
532 PN_PIPE_DISABLE ); |
555 //old pep |
533 //old pep |
556 isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_OLDPEPDEV, |
534 isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_OLDPEPDEV, |
557 iPipeTable[aDteId].iSecondDevId ); |
535 iPipe.secondDevId ); |
558 isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_OLDPEPOBJ, |
536 isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_OLDPEPOBJ, |
559 iPipeTable[aDteId].iSecondObjId ); |
537 iPipe.secondObjId ); |
560 isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_OLDPEPTYPE, PN_PEP_TYPE_COMMON); |
538 isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_OLDPEPTYPE, PN_PEP_TYPE_COMMON); |
561 isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_FILLERBYTE1, KFiller ); |
539 isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_FILLERBYTE1, KFiller ); |
562 |
540 |
563 isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_REPLACEMENTPEPDEV, aNewDevId ); |
541 isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_REPLACEMENTPEPDEV, aNewDevId ); |
564 isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_REPLACEMENTPEPOBJ, aNewObjId ); |
542 isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_REPLACEMENTPEPOBJ, aNewObjId ); |
565 isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_REPLACEMENTPEPTYPE, |
543 isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_REPLACEMENTPEPTYPE, |
566 PN_PEP_TYPE_COMMON ); |
544 PN_PEP_TYPE_COMMON ); |
567 |
545 |
568 iPipeTable[aDteId].iSecondDevId = aNewDevId; |
546 iPipe.secondDevId = aNewDevId; |
569 iPipeTable[aDteId].iSecondObjId = aNewObjId; |
547 iPipe.secondObjId = aNewObjId; |
570 |
548 |
571 isimessage.Set8bit(ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_NSB, KFiller ); |
549 isimessage.Set8bit(ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_NSB, KFiller ); |
572 isimessage.Complete(); |
550 isimessage.Complete(); |
573 |
551 |
574 C_TRACE(_L("Created ISI-message")); |
552 C_TRACE(_L("Created ISI-message")); |
583 TInt error = aReceivedMessage.Get8bit( ISI_HEADER_SIZE + |
561 TInt error = aReceivedMessage.Get8bit( ISI_HEADER_SIZE + |
584 PNS_PIPE_REDIRECT_RESP_OFFSET_ERRORCODE ); |
562 PNS_PIPE_REDIRECT_RESP_OFFSET_ERRORCODE ); |
585 TInt pipeHandle = aReceivedMessage.Get8bit( ISI_HEADER_SIZE + |
563 TInt pipeHandle = aReceivedMessage.Get8bit( ISI_HEADER_SIZE + |
586 PNS_PIPE_REDIRECT_RESP_OFFSET_PIPEHANDLE ); |
564 PNS_PIPE_REDIRECT_RESP_OFFSET_PIPEHANDLE ); |
587 C_TRACE((_L("CModemAtPipeController::HandlePipeRedirectResp() pipehandle: %d"), pipeHandle )); |
565 C_TRACE((_L("CModemAtPipeController::HandlePipeRedirectResp() pipehandle: %d"), pipeHandle )); |
588 TInt dteId = FindDteId( pipeHandle ); |
|
589 |
566 |
590 if( error != PN_PIPE_NO_ERROR ) |
567 if( error != PN_PIPE_NO_ERROR ) |
591 { |
568 { |
592 if( dteId != KInvalidDteId ) |
569 if( pipeHandle == iPipe.pipeHandle ) |
593 { |
570 { |
594 C_TRACE(( _L("CModemAtPipeController::HandlePipeRedirectResp() pipe error: %d"), error )); |
571 C_TRACE(( _L("CModemAtPipeController::HandlePipeRedirectResp() pipe error: %d"), error )); |
595 iAtHandler.SendAtModemDataRedirectResultReq( dteId, AT_MODEM_REDIRECT_RESULT_ERROR); |
572 iAtHandler.SendAtModemDataRedirectResultReq( pipeHandle, AT_MODEM_REDIRECT_RESULT_ERROR); |
596 RemovePipe( dteId ); |
573 RemovePipe( pipeHandle ); |
597 return; |
574 return; |
598 } |
575 } |
599 else |
576 else |
600 { |
577 { |
601 C_TRACE(( _L("CModemAtPipeController::HandlePipeRedirectResp() dteId not found, pipe error: %d"), error )); |
578 C_TRACE(( _L("CModemAtPipeController::HandlePipeRedirectResp() pipeHandle not found, pipe error: %d"), error )); |
602 TRACE_ASSERT_ALWAYS; |
579 TRACE_ASSERT_ALWAYS; |
603 return; |
580 return; |
604 } |
581 } |
605 } |
582 } |
606 |
583 |
607 iAtHandler.SendAtModemDataRedirectResultReq( dteId, AT_MODEM_REDIRECT_RESULT_OK ); |
584 if( pipeHandle != iPipe.pipeHandle ) |
608 |
585 { |
609 if( iPipeTable[ dteId ].iPipeState != TPipeInfo::EPipeDisabled ) |
586 C_TRACE(( _L("CModemAtPipeController::HandlePipeRedirectResp() unknown pipehandle %d"), pipeHandle )); |
|
587 TRACE_ASSERT_ALWAYS; |
|
588 return; |
|
589 } |
|
590 |
|
591 iAtHandler.SendAtModemDataRedirectResultReq( pipeHandle, AT_MODEM_REDIRECT_RESULT_OK ); |
|
592 |
|
593 if( iPipe.pipeState != TPipeInfo::EPipeDisabled ) |
610 { |
594 { |
611 SendEnablePipeReq( pipeHandle ); |
595 SendEnablePipeReq( pipeHandle ); |
612 } |
596 } |
613 |
|
614 } |
597 } |
615 |
598 |
616 void CModemAtPipeController::QueryModemAtFromNameService() |
599 void CModemAtPipeController::QueryModemAtFromNameService() |
617 { |
600 { |
618 C_TRACE (( _T("CModemAtPipeController::QueryModemAtFromNameService()") )); |
601 C_TRACE (( _T("CModemAtPipeController::QueryModemAtFromNameService()") )); |
656 TInt retVal = iIscApi.Send( messageptr ); |
639 TInt retVal = iIscApi.Send( messageptr ); |
657 TRACE_ASSERT( retVal == KErrNone ); |
640 TRACE_ASSERT( retVal == KErrNone ); |
658 delete message; |
641 delete message; |
659 } |
642 } |
660 |
643 |
661 TInt CModemAtPipeController::FindDteId( const TInt aHandle ) |
|
662 { |
|
663 C_TRACE (( _T("CModemAtPipeController::FindDteId()") )); |
|
664 TInt dteId = KInvalidDteId; |
|
665 for( TInt i = 0 ; i < KMaxDteIdCount ; i++ ) |
|
666 { |
|
667 if( iPipeTable[i].iHandle == aHandle ) |
|
668 { |
|
669 dteId = i; |
|
670 break; |
|
671 } |
|
672 } |
|
673 |
|
674 TRACE_ASSERT( dteId != KInvalidDteId ); |
|
675 C_TRACE((_L("CModemAtPipeController::FindDteId() returns dteid: %d"),dteId)); |
|
676 return dteId; |
|
677 } |
|
678 |
|
679 |
|
680 void CModemAtPipeController::HandlePipeEnabledResp( const TIsiReceiveC& aReceivedMessage ) |
644 void CModemAtPipeController::HandlePipeEnabledResp( const TIsiReceiveC& aReceivedMessage ) |
681 { |
645 { |
682 C_TRACE (( _T("CModemAtPipeController::HandlePipeEnabledResp()") )); |
646 C_TRACE (( _T("CModemAtPipeController::HandlePipeEnabledResp()") )); |
683 TInt error = aReceivedMessage.Get8bit(ISI_HEADER_SIZE + |
647 TInt error = aReceivedMessage.Get8bit(ISI_HEADER_SIZE + |
684 PNS_PIPE_ENABLE_RESP_OFFSET_ERRORCODE); |
648 PNS_PIPE_ENABLE_RESP_OFFSET_ERRORCODE); |
685 TInt pipeHandle = aReceivedMessage.Get8bit(ISI_HEADER_SIZE + |
649 TInt pipeHandle = aReceivedMessage.Get8bit(ISI_HEADER_SIZE + |
686 PNS_PIPE_ENABLE_RESP_OFFSET_PIPEHANDLE); |
650 PNS_PIPE_ENABLE_RESP_OFFSET_PIPEHANDLE); |
687 TInt dteId = FindDteId(pipeHandle); |
651 if( pipeHandle != iPipe.pipeHandle ) |
|
652 { |
|
653 C_TRACE((_L("CModemAtPipeController::HandlePipeEnabledResp() unknown pipeHandle received"))); |
|
654 TRACE_ASSERT_ALWAYS; |
|
655 return; |
|
656 } |
|
657 |
688 C_TRACE((_L("CModemAtPipeController::HandlePipeEnabledResp() pipehandle %d"), pipeHandle)); |
658 C_TRACE((_L("CModemAtPipeController::HandlePipeEnabledResp() pipehandle %d"), pipeHandle)); |
689 |
659 |
690 if( error == PN_PIPE_NO_ERROR ) |
660 if( error == PN_PIPE_NO_ERROR ) |
691 { |
661 { |
692 ChangePipeState( dteId, TPipeInfo::EPipeEnabled ); |
662 ChangePipeState( TPipeInfo::EPipeEnabled ); |
693 } |
663 } |
694 else |
664 else |
695 { |
665 { |
696 C_TRACE((_L("CModemAtPipeController::HandlePipeEnabledResp() pipe error: %d"), error)); |
666 C_TRACE((_L("CModemAtPipeController::HandlePipeEnabledResp() pipe error: %d"), error)); |
697 TRACE_ASSERT_ALWAYS; |
667 TRACE_ASSERT_ALWAYS; |
698 } |
668 } |
699 } |
669 } |
700 |
670 |
701 |
671 |
702 void CModemAtPipeController::ChangePipeState( |
672 void CModemAtPipeController::ChangePipeState( TPipeInfo::EPipeState aState ) |
703 const TInt aDteId, |
673 { |
704 TPipeInfo::EPipeState aState ) |
674 C_TRACE((_L("CModemAtPipeController::ChangePipeState( New state: %d )"), (TInt)aState)); |
705 { |
675 C_TRACE(( _L("Old iPipe.pipeState = %d"), (TInt)iPipe.pipeState )); |
706 C_TRACE((_L("CModemAtPipeController::ChangePipeState(%d, %d)"), aDteId, aState)); |
676 iPipe.pipeState = aState; |
707 C_TRACE(( _L("Was: iPipeTable[ %d ].iPipeState = %d"), aDteId, (TInt)iPipeTable[ aDteId ].iPipeState )); |
|
708 iPipeTable[ aDteId ].iPipeState = aState; |
|
709 if( aState == TPipeInfo::EPipeEnabled ) |
677 if( aState == TPipeInfo::EPipeEnabled ) |
710 { |
678 { |
711 C_TRACE(( _T("DATA MODE") )); |
679 C_TRACE(( _T("DATA MODE") )); |
712 iAtHandler.HandleCommandModeChange( aDteId, EDataMode ); |
680 iAtHandler.HandleCommandModeChange( EDataMode ); |
713 } |
681 } |
714 else if( aState == TPipeInfo::EPipeDisabled ) |
682 else if( aState == TPipeInfo::EPipeDisabled ) |
715 { |
683 { |
716 C_TRACE(( _T("COMMAND MODE") )); |
684 C_TRACE(( _T("COMMAND MODE") )); |
717 iAtHandler.HandleCommandModeChange( aDteId, ECommandMode ); |
685 iAtHandler.HandleCommandModeChange( ECommandMode ); |
718 } |
686 } |
719 } |
687 } |
720 |
688 |
721 void CModemAtPipeController::HandlePepStatusInd( const TIsiReceiveC& aReceivedMessage ) |
689 void CModemAtPipeController::HandlePepStatusInd( const TIsiReceiveC& aReceivedMessage ) |
722 { |
690 { |
729 PNS_PEP_STATUS_IND_OFFSET_INDICATIONID ) ); |
697 PNS_PEP_STATUS_IND_OFFSET_INDICATIONID ) ); |
730 if( indicationId == PEP_COMM_IND_ID_ESCAPE ) |
698 if( indicationId == PEP_COMM_IND_ID_ESCAPE ) |
731 { |
699 { |
732 TUint8 pipeHandle( aReceivedMessage.Get8bit( ISI_HEADER_SIZE + |
700 TUint8 pipeHandle( aReceivedMessage.Get8bit( ISI_HEADER_SIZE + |
733 PNS_PEP_STATUS_IND_OFFSET_PIPEHANDLE ) ); |
701 PNS_PEP_STATUS_IND_OFFSET_PIPEHANDLE ) ); |
734 TInt dteId( FindDteId( pipeHandle ) ); |
702 |
735 C_TRACE( (_L("CModemAtPipeController PEP_COMM_IND_ID_ESCAPE received, pipehandle %d dteid %d"), pipeHandle, dteId )); |
703 C_TRACE( (_L("CModemAtPipeController PEP_COMM_IND_ID_ESCAPE received, pipehandle: %d iPipe.pipeHandle: %d"), pipeHandle, iPipe.pipeHandle )); |
736 |
704 |
737 if( dteId != KInvalidDteId ) |
705 if( pipeHandle == iPipe.pipeHandle ) |
738 { |
706 { |
739 C_TRACE( (_L("SendEscapeSignalDetection dteid %d"), dteId )); |
707 C_TRACE( (_L("SendEscapeSignalDetection dteid %d"), pipeHandle )); |
740 iAtHandler.SendEscapeSignalDetection( dteId ); |
708 iAtHandler.SendEscapeSignalDetection( pipeHandle ); |
741 } |
709 } |
742 } |
710 } |
743 // Not know should any other indicationid from comm pep type to be handled |
711 // Not know should any other indicationid from comm pep type to be handled |
744 else |
712 else |
745 { |
713 { |