119 if ( retTrap != KErrNone ) |
119 if ( retTrap != KErrNone ) |
120 { |
120 { |
121 FTRACE(FPrint( _L("CDunUpstream::InitializeForAtParsing() (trapped!) complete" ) )); |
121 FTRACE(FPrint( _L("CDunUpstream::InitializeForAtParsing() (trapped!) complete" ) )); |
122 return retTrap; |
122 return retTrap; |
123 } |
123 } |
|
124 // Note: the order of the added callbacks is important. When a mode change |
|
125 // occurs, it is best to do the most important stuff with the first callback |
|
126 // object and after this cleanups with the second. Example: Data mode start |
|
127 // should stop command handling; first callback stops command handling, |
|
128 // second callback stops multiplexer (doing this differently could cause the |
|
129 // multiplexer to re-activate). |
124 atCmdHandler->AddCmdModeCallback( aCallbackUp ); |
130 atCmdHandler->AddCmdModeCallback( aCallbackUp ); |
125 atCmdHandler->AddCmdModeCallback( aCallbackDown ); |
131 atCmdHandler->AddCmdModeCallback( aCallbackDown ); |
126 iParseData.iDataMode = EFalse; |
132 iParseData.iDataMode = EFalse; |
127 iParseData.iAtCmdHandler = atCmdHandler; |
133 iParseData.iAtCmdHandler = atCmdHandler; |
128 FTRACE(FPrint( _L("CDunUpstream::InitializeForAtParsing() complete" ) )); |
134 FTRACE(FPrint( _L("CDunUpstream::InitializeForAtParsing() complete" ) )); |
187 FTRACE(FPrint( _L("CDunUpstream::Stop() (Network) cancelled" ))); |
193 FTRACE(FPrint( _L("CDunUpstream::Stop() (Network) cancelled" ))); |
188 } |
194 } |
189 } |
195 } |
190 Cancel(); |
196 Cancel(); |
191 iTransferState = EDunStateIdle; |
197 iTransferState = EDunStateIdle; |
|
198 iOperationType = EDunOperationTypeUndefined; |
192 // Notify parent about inactivity |
199 // Notify parent about inactivity |
193 if ( iActivityData.iActivityCallback && iActivityData.iNotified ) |
200 if ( iActivityData.iActivityCallback && iActivityData.iNotified ) |
194 { |
201 { |
195 iActivityData.iActivityCallback->NotifyChannelInactivity(); |
202 iActivityData.iActivityCallback->NotifyChannelInactivity(); |
196 iActivityData.iNotified = EFalse; |
203 iActivityData.iNotified = EFalse; |
277 { |
284 { |
278 case EDunReaderUpstream: |
285 case EDunReaderUpstream: |
279 if ( iComm ) |
286 if ( iComm ) |
280 { |
287 { |
281 iStatus = KRequestPending; |
288 iStatus = KRequestPending; |
|
289 iTransferState = EDunStateTransferring; |
282 iComm->ReadOneOrMore( iStatus, *iBufferPtr ); |
290 iComm->ReadOneOrMore( iStatus, *iBufferPtr ); |
|
291 SetActive(); |
283 FTRACE(FPrint( _L("CDunUpstream::IssueRequest() RComm ReadOneOrMore() requested" ) )); |
292 FTRACE(FPrint( _L("CDunUpstream::IssueRequest() RComm ReadOneOrMore() requested" ) )); |
284 } |
293 } |
285 else if ( iSocket ) |
294 else if ( iSocket ) |
286 { |
295 { |
287 iStatus = KRequestPending; |
296 iStatus = KRequestPending; |
|
297 iTransferState = EDunStateTransferring; |
288 iSocket->RecvOneOrMore( *iBufferPtr, 0, iStatus, iReadLengthSocket ); |
298 iSocket->RecvOneOrMore( *iBufferPtr, 0, iStatus, iReadLengthSocket ); |
|
299 SetActive(); |
289 FTRACE(FPrint( _L("CDunUpstream::IssueRequest() RSocket RecvOneOrMore() requested" ) )); |
300 FTRACE(FPrint( _L("CDunUpstream::IssueRequest() RSocket RecvOneOrMore() requested" ) )); |
290 } |
301 } |
291 else |
302 else |
292 { |
303 { |
293 FTRACE(FPrint( _L("CDunUpstream::IssueRequest() (ERROR) complete" ) )); |
304 FTRACE(FPrint( _L("CDunUpstream::IssueRequest() (ERROR) complete" ) )); |
294 return KErrGeneral; |
305 return KErrGeneral; |
295 } |
306 } |
296 break; |
307 break; |
297 case EDunWriterUpstream: |
308 case EDunWriterUpstream: |
298 iStatus = KRequestPending; |
309 iStatus = KRequestPending; |
|
310 iTransferState = EDunStateTransferring; |
299 iNetwork->Write( iStatus, *iBufferPtr ); |
311 iNetwork->Write( iStatus, *iBufferPtr ); |
|
312 SetActive(); |
300 FTRACE(FPrint( _L("CDunUpstream::IssueRequest() RComm Write() requested" ) )); |
313 FTRACE(FPrint( _L("CDunUpstream::IssueRequest() RComm Write() requested" ) )); |
301 break; |
314 break; |
302 default: |
315 default: |
303 FTRACE(FPrint( _L("CDunUpstream::IssueRequest() (ERROR) complete" ) )); |
316 FTRACE(FPrint( _L("CDunUpstream::IssueRequest() (ERROR) complete" ) )); |
304 return KErrGeneral; |
317 return KErrGeneral; |
305 } |
318 } |
306 |
|
307 SetActive(); |
|
308 iTransferState = EDunStateTransferring; |
|
309 |
319 |
310 FTRACE(FPrint( _L("CDunUpstream::IssueRequest() (Dir=%d) complete" ), iDirection)); |
320 FTRACE(FPrint( _L("CDunUpstream::IssueRequest() (Dir=%d) complete" ), iDirection)); |
311 return KErrNone; |
321 return KErrNone; |
312 } |
322 } |
313 |
323 |
438 // Gets called on cancel |
448 // Gets called on cancel |
439 // --------------------------------------------------------------------------- |
449 // --------------------------------------------------------------------------- |
440 // |
450 // |
441 void CDunUpstream::DoCancel() |
451 void CDunUpstream::DoCancel() |
442 { |
452 { |
|
453 FTRACE(FPrint( _L("CDunUpstream::DoCancel()" ))); |
|
454 FTRACE(FPrint( _L("CDunUpstream::DoCancel() complete" ))); |
443 } |
455 } |
444 |
456 |
445 // --------------------------------------------------------------------------- |
457 // --------------------------------------------------------------------------- |
446 // From class MDunAtCmdStatusReporter |
458 // From class MDunAtCmdStatusReporter |
447 // Notifies about parser's need to get more data |
459 // Notifies about parser's need to get more data |
448 // --------------------------------------------------------------------------- |
460 // --------------------------------------------------------------------------- |
449 // |
461 // |
450 void CDunUpstream::NotifyParserNeedsMoreData() |
462 void CDunUpstream::NotifyParserNeedsMoreData() |
451 { |
463 { |
452 FTRACE(FPrint( _L("CDunUpstream::NotifyParserNeedsMoreData()" ))); |
464 FTRACE(FPrint( _L("CDunUpstream::NotifyParserNeedsMoreData()" ))); |
|
465 if ( iOperationType != EDunOperationTypeRead ) |
|
466 { |
|
467 FTRACE(FPrint( _L("CDunUpstream::NotifyParserNeedsMoreData() (not ready) complete" ))); |
|
468 return; |
|
469 } |
453 IssueRequest(); // iOperationType must be read here (don't set) |
470 IssueRequest(); // iOperationType must be read here (don't set) |
454 FTRACE(FPrint( _L("CDunUpstream::NotifyParserNeedsMoreData() complete" ))); |
471 FTRACE(FPrint( _L("CDunUpstream::NotifyParserNeedsMoreData() complete" ))); |
455 } |
472 } |
456 |
473 |
457 // --------------------------------------------------------------------------- |
474 // --------------------------------------------------------------------------- |
548 { |
565 { |
549 FTRACE(FPrint( _L("CDunUpstream::NotifyCommandModeEnd()" ))); |
566 FTRACE(FPrint( _L("CDunUpstream::NotifyCommandModeEnd()" ))); |
550 iParseData.iDataMode = ETrue; |
567 iParseData.iDataMode = ETrue; |
551 // Stop processing (mandatory). |
568 // Stop processing (mandatory). |
552 // This will stop any possibly pending operations of |
569 // This will stop any possibly pending operations of |
553 // CDunAtCmdHandler and CDunAtUrcHandler. CDunDownstream will take care of |
570 // CDunAtCmdHandler and CDunAtUrcHandler(s). CDunDownstream will take care |
554 // clearing (and stopping) non-callback write queues. |
571 // of clearing (and stopping) non-callback write queues. |
555 StopAtCmdHandling(); |
572 StopAtCmdHandling(); |
556 // The follow is needed because stopping the AT command handling here |
573 // The following is needed here because stopping the AT command handling |
557 // prevents the subsequent AT command handling notification to reach the |
574 // causes CDunAtCmdHandler not to call NotifyParserNeedsMoreData(). |
558 // NotifyAtCmdHandlingEnd() in this class (the notification starts from |
575 // In command mode iOperationType is always EDunOperationTypeRead. |
559 // CDunAtCmdPusher's SetToIdleAndNotifyEnd()). |
|
560 // So here we have to do the block "if ( aStartIndex < 0 )" in function |
|
561 // NotifyAtCmdHandlingEnd(). |
|
562 IssueRequest(); |
576 IssueRequest(); |
563 FTRACE(FPrint( _L("CDunUpstream::NotifyCommandModeEnd() complete" ))); |
577 FTRACE(FPrint( _L("CDunUpstream::NotifyCommandModeEnd() complete" ))); |
564 } |
578 } |
565 |
579 |
566 // --------------------------------------------------------------------------- |
580 // --------------------------------------------------------------------------- |
569 // --------------------------------------------------------------------------- |
583 // --------------------------------------------------------------------------- |
570 // |
584 // |
571 void CDunUpstream::NotifyEchoComplete() |
585 void CDunUpstream::NotifyEchoComplete() |
572 { |
586 { |
573 FTRACE(FPrint( _L("CDunUpstream::NotifyEchoComplete()" ))); |
587 FTRACE(FPrint( _L("CDunUpstream::NotifyEchoComplete()" ))); |
|
588 // iOperationType is always EDunOperationTypeRead here |
574 IssueRequest(); |
589 IssueRequest(); |
575 FTRACE(FPrint( _L("CDunUpstream::NotifyEchoComplete() complete" ))); |
590 FTRACE(FPrint( _L("CDunUpstream::NotifyEchoComplete() complete" ))); |
576 } |
591 } |