|
1 /* |
|
2 * Copyright (c) 2008-2010 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 "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: Definitions needed for one "stream" of CDunTransporter |
|
15 * |
|
16 */ |
|
17 |
|
18 /* |
|
19 * TODO: When local media is of type RComm, listening on it is started with |
|
20 * RComm::NotifyDataAvailable() call. Check that USB ACM port and Irda RCOMM |
|
21 * (and any other new media in the future) behaves correctly so that when |
|
22 * RComm::ReadOneOrMore() is issued, the read is issued immediately without |
|
23 * checking for new data. If waiting for new data happens in this |
|
24 * NotifyDataAvailable/ReadOneOrMore combination, raise a defect to Symbian. |
|
25 */ |
|
26 |
|
27 #include "DunTransporter.h" |
|
28 #include "DunUpstream.h" |
|
29 #include "DunDebug.h" |
|
30 |
|
31 // --------------------------------------------------------------------------- |
|
32 // Two-phased constructor. |
|
33 // --------------------------------------------------------------------------- |
|
34 // |
|
35 CDunUpstream* CDunUpstream::NewL( MDunTransporterUtilityAux* aUtility ) |
|
36 { |
|
37 CDunUpstream* self = new (ELeave) CDunUpstream( aUtility ); |
|
38 CleanupStack::PushL( self ); |
|
39 self->ConstructL(); |
|
40 CleanupStack::Pop( self ); |
|
41 return self; |
|
42 } |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // Destructor. |
|
46 // --------------------------------------------------------------------------- |
|
47 // |
|
48 CDunUpstream::~CDunUpstream() |
|
49 { |
|
50 FTRACE(FPrint( _L("CDunUpstream::~CDunUpstream()" ))); |
|
51 ResetData(); |
|
52 FTRACE(FPrint( _L("CDunUpstream::~CDunUpstream() complete" ))); |
|
53 } |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // Resets data to initial values |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 void CDunUpstream::ResetData() |
|
60 { |
|
61 // APIs affecting this: |
|
62 // IssueRequest() |
|
63 Stop(); |
|
64 // InitializeForAtParsing() |
|
65 delete iParseData.iAtCmdHandler; |
|
66 iParseData.iAtCmdHandler = NULL; |
|
67 // AddConnMonCallbackL() |
|
68 iCallbacksR.Close(); |
|
69 iCallbacksW.Close(); |
|
70 // AddSkippedErrorL() |
|
71 iOkErrorsR.Close(); |
|
72 iOkErrorsW.Close(); |
|
73 // Internal |
|
74 Initialize(); |
|
75 } |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // Sets activity callback for this stream |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 TInt CDunUpstream::SetActivityCallback( |
|
82 MDunActivityManager* aActivityCallback ) |
|
83 { |
|
84 if ( !aActivityCallback ) |
|
85 { |
|
86 FTRACE(FPrint( _L("CDunUpstream::SetActivityCallback() (aActivityCallback) not initialized!" ) )); |
|
87 return KErrGeneral; |
|
88 } |
|
89 if ( iActivityData.iActivityCallback ) |
|
90 { |
|
91 FTRACE(FPrint( _L("CDunUpstream::SetActivityCallback() (already exists) complete" ) )); |
|
92 return KErrAlreadyExists; |
|
93 } |
|
94 iActivityData.iActivityCallback = aActivityCallback; |
|
95 return KErrNone; |
|
96 } |
|
97 |
|
98 // --------------------------------------------------------------------------- |
|
99 // Initializes this stream for AT command notifications |
|
100 // --------------------------------------------------------------------------- |
|
101 // |
|
102 TInt CDunUpstream::InitializeForAtParsing( |
|
103 MDunStreamManipulator* aStreamCallback, |
|
104 const TDesC8* aConnectionName, |
|
105 MDunCmdModeMonitor* aCallbackUp, |
|
106 MDunCmdModeMonitor* aCallbackDown ) |
|
107 { |
|
108 FTRACE(FPrint( _L("CDunUpstream::InitializeForAtParsing()" ) )); |
|
109 if ( iParseData.iAtCmdHandler ) |
|
110 { |
|
111 FTRACE(FPrint( _L("CDunUpstream::InitializeForAtParsing() (already exists) complete" ) )); |
|
112 return KErrAlreadyExists; |
|
113 } |
|
114 TInt retTrap = KErrNone; |
|
115 CDunAtCmdHandler* atCmdHandler = NULL; |
|
116 TRAP( retTrap, atCmdHandler = CDunAtCmdHandler::NewL(this, |
|
117 aStreamCallback, |
|
118 aConnectionName) ); |
|
119 if ( retTrap != KErrNone ) |
|
120 { |
|
121 FTRACE(FPrint( _L("CDunUpstream::InitializeForAtParsing() (trapped!) complete" ) )); |
|
122 return retTrap; |
|
123 } |
|
124 atCmdHandler->AddCmdModeCallback( aCallbackUp ); |
|
125 atCmdHandler->AddCmdModeCallback( aCallbackDown ); |
|
126 iParseData.iDataMode = EFalse; |
|
127 iParseData.iParseNeeded = ETrue; |
|
128 iParseData.iHandling = EFalse; |
|
129 iParseData.iAtCmdHandler = atCmdHandler; |
|
130 FTRACE(FPrint( _L("CDunUpstream::InitializeForAtParsing() complete" ) )); |
|
131 return KErrNone; |
|
132 } |
|
133 |
|
134 // --------------------------------------------------------------------------- |
|
135 // Starts upstream by issuing read request |
|
136 // --------------------------------------------------------------------------- |
|
137 // |
|
138 TInt CDunUpstream::StartStream() |
|
139 { |
|
140 FTRACE(FPrint( _L("CDunUpstream::StartStream()" ) )); |
|
141 if ( !iNetwork ) |
|
142 { |
|
143 FTRACE(FPrint( _L("CDunUpstream::StartStream() (iNetwork) not initialized!" ) )); |
|
144 return KErrGeneral; |
|
145 } |
|
146 if ( !iComm && !iSocket ) |
|
147 { |
|
148 FTRACE(FPrint( _L("CDunUpstream::StartStream() (iComm&iSocket) not initialized!" ) )); |
|
149 return KErrGeneral; |
|
150 } |
|
151 iOperationType = EDunOperationTypeRead; |
|
152 TInt retVal = IssueRequest(); |
|
153 FTRACE(FPrint( _L("CDunUpstream::StartStream() complete" ) )); |
|
154 return retVal; |
|
155 } |
|
156 |
|
157 // --------------------------------------------------------------------------- |
|
158 // Stops transfer for read or write endpoints |
|
159 // --------------------------------------------------------------------------- |
|
160 // |
|
161 TInt CDunUpstream::Stop() |
|
162 { |
|
163 FTRACE(FPrint( _L("CDunUpstream::Stop() (Dir=%d)" ), iDirection)); |
|
164 // Don't stop CDunAtCmdHandler here as it is downstream related! |
|
165 if ( iTransferState != EDunStateTransferring ) |
|
166 { |
|
167 FTRACE(FPrint( _L("CDunUpstream::Stop() (not ready) complete" ))); |
|
168 return KErrNotReady; |
|
169 } |
|
170 // Stop only current operation |
|
171 if ( iOperationType == EDunOperationTypeRead ) |
|
172 { |
|
173 if ( iComm ) |
|
174 { |
|
175 iComm->ReadCancel(); |
|
176 FTRACE(FPrint( _L("CDunUpstream::Stop() (RComm) cancelled" ))); |
|
177 } |
|
178 else if ( iSocket ) |
|
179 { |
|
180 iSocket->CancelRecv(); |
|
181 FTRACE(FPrint( _L("CDunUpstream::Stop() (RSocket) cancelled" ))); |
|
182 } |
|
183 } |
|
184 else if ( iOperationType == EDunOperationTypeWrite ) |
|
185 { |
|
186 if ( iNetwork ) |
|
187 { |
|
188 iNetwork->WriteCancel(); |
|
189 FTRACE(FPrint( _L("CDunUpstream::Stop() (Network) cancelled" ))); |
|
190 } |
|
191 } |
|
192 Cancel(); |
|
193 iTransferState = EDunStateIdle; |
|
194 // Notify parent about inactivity |
|
195 if ( iActivityData.iActivityCallback && iActivityData.iNotified ) |
|
196 { |
|
197 iActivityData.iActivityCallback->NotifyChannelInactivity(); |
|
198 iActivityData.iNotified = EFalse; |
|
199 } |
|
200 FTRACE(FPrint( _L("CDunUpstream::Stop() complete" ))); |
|
201 return KErrNone; |
|
202 } |
|
203 |
|
204 // --------------------------------------------------------------------------- |
|
205 // Data transmission state (if read completed) |
|
206 // --------------------------------------------------------------------------- |
|
207 // |
|
208 TBool CDunUpstream::DataReadStatus() |
|
209 { |
|
210 return iActivityData.iDataRead; |
|
211 } |
|
212 |
|
213 // --------------------------------------------------------------------------- |
|
214 // CDunUpstream::CDunUpstream |
|
215 // --------------------------------------------------------------------------- |
|
216 // |
|
217 CDunUpstream::CDunUpstream( MDunTransporterUtilityAux* aUtility ) : |
|
218 iUtility( aUtility ) |
|
219 { |
|
220 Initialize(); |
|
221 } |
|
222 |
|
223 // --------------------------------------------------------------------------- |
|
224 // CDunUpstream::ConstructL |
|
225 // --------------------------------------------------------------------------- |
|
226 // |
|
227 void CDunUpstream::ConstructL() |
|
228 { |
|
229 FTRACE(FPrint( _L("CDunUpstream::ConstructL()" ) )); |
|
230 if ( !iUtility ) |
|
231 { |
|
232 User::Leave( KErrGeneral ); |
|
233 } |
|
234 FTRACE(FPrint( _L("CDunUpstream::ConstructL() complete" ) )); |
|
235 } |
|
236 |
|
237 // --------------------------------------------------------------------------- |
|
238 // Initializes this class |
|
239 // --------------------------------------------------------------------------- |
|
240 // |
|
241 void CDunUpstream::Initialize() |
|
242 { |
|
243 // Don't initialize iUtility here (it is set through NewL) |
|
244 iActivityData.iActivityCallback = NULL; |
|
245 iActivityData.iDataRead = EFalse; |
|
246 iActivityData.iNotified = EFalse; |
|
247 iParseData.iDataMode = EFalse; |
|
248 iParseData.iParseNeeded = EFalse; |
|
249 iParseData.iHandling = EFalse; |
|
250 iParseData.iAtCmdHandler = NULL; |
|
251 } |
|
252 |
|
253 // --------------------------------------------------------------------------- |
|
254 // Issues transfer request for this stream |
|
255 // --------------------------------------------------------------------------- |
|
256 // |
|
257 TInt CDunUpstream::IssueRequest() |
|
258 { |
|
259 // Set direction |
|
260 iDirection = static_cast<TDunDirection>( EDunStreamTypeUpstream | iOperationType ); |
|
261 |
|
262 FTRACE(FPrint( _L("CDunUpstream::IssueRequest() (Dir=%d)" ), iDirection)); |
|
263 |
|
264 if ( iTransferState != EDunStateIdle ) |
|
265 { |
|
266 FTRACE(FPrint( _L("CDunUpstream::IssueRequest() (not ready) complete" ) )); |
|
267 return KErrNotReady; |
|
268 } |
|
269 |
|
270 if ( iOperationType == EDunOperationTypeRead ) |
|
271 { |
|
272 iBufferPtr->SetLength( iBufferPtr->MaxLength() ); |
|
273 FTRACE(FPrint( _L("CDunUpstream::IssueRequest() trying to read %d bytes... (Dir=%d)" ), iBufferPtr->Length(), iDirection)); |
|
274 } |
|
275 else // iOperationType == EDunOperationTypeWrite |
|
276 { |
|
277 FTRACE(FPrint( _L("CDunUpstream::IssueRequest() writing %d bytes... (Dir=%d)" ), iBufferPtr->Length(), iDirection)); |
|
278 } |
|
279 |
|
280 switch ( iDirection ) |
|
281 { |
|
282 case EDunReaderUpstream: |
|
283 if ( iComm ) |
|
284 { |
|
285 iStatus = KRequestPending; |
|
286 iComm->ReadOneOrMore( iStatus, *iBufferPtr ); |
|
287 FTRACE(FPrint( _L("CDunUpstream::IssueRequest() RComm ReadOneOrMore() requested" ) )); |
|
288 } |
|
289 else if ( iSocket ) |
|
290 { |
|
291 iStatus = KRequestPending; |
|
292 iSocket->RecvOneOrMore( *iBufferPtr, 0, iStatus, iReadLengthSocket ); |
|
293 FTRACE(FPrint( _L("CDunUpstream::IssueRequest() RSocket RecvOneOrMore() requested" ) )); |
|
294 } |
|
295 else |
|
296 { |
|
297 FTRACE(FPrint( _L("CDunUpstream::IssueRequest() (ERROR) complete" ) )); |
|
298 return KErrGeneral; |
|
299 } |
|
300 break; |
|
301 case EDunWriterUpstream: |
|
302 iStatus = KRequestPending; |
|
303 iNetwork->Write( iStatus, *iBufferPtr ); |
|
304 FTRACE(FPrint( _L("CDunUpstream::IssueRequest() RComm Write() requested" ) )); |
|
305 break; |
|
306 default: |
|
307 FTRACE(FPrint( _L("CDunUpstream::IssueRequest() (ERROR) complete" ) )); |
|
308 return KErrGeneral; |
|
309 } |
|
310 |
|
311 SetActive(); |
|
312 iTransferState = EDunStateTransferring; |
|
313 |
|
314 FTRACE(FPrint( _L("CDunUpstream::IssueRequest() (Dir=%d) complete" ), iDirection)); |
|
315 return KErrNone; |
|
316 } |
|
317 |
|
318 // --------------------------------------------------------------------------- |
|
319 // Processes data that was read |
|
320 // --------------------------------------------------------------------------- |
|
321 // |
|
322 TBool CDunUpstream::ProcessReadData() |
|
323 { |
|
324 FTRACE(FPrint( _L("CDunUpstream::ProcessReadData()" ))); |
|
325 // The following will be transferred to Dataport |
|
326 if ( iParseData.iDataMode || !iParseData.iParseNeeded ) |
|
327 { |
|
328 iOperationType = EDunOperationTypeWrite; |
|
329 FTRACE(FPrint( _L("CDunUpstream::ProcessReadData() (next write) complete" ))); |
|
330 return ETrue; |
|
331 } |
|
332 if ( !iParseData.iAtCmdHandler ) // optional |
|
333 { |
|
334 FTRACE(FPrint( _L("CDunUpstream::ProcessReadData() (no handler) complete" ))); |
|
335 return ETrue; |
|
336 } |
|
337 // The following will be transferred to parser |
|
338 TInt retTemp = KErrNone; |
|
339 TBool partialInput = EFalse; |
|
340 retTemp = iParseData.iAtCmdHandler->ParseCommand( *iBufferPtr, |
|
341 partialInput ); |
|
342 if ( retTemp!=KErrNone || !partialInput ) |
|
343 { |
|
344 FTRACE(FPrint( _L("CDunUpstream::ProcessReadData() (no reissue) complete" ))); |
|
345 return EFalse; |
|
346 } |
|
347 FTRACE(FPrint( _L("CDunUpstream::ProcessReadData() (reissue) complete" ))); |
|
348 return ETrue; |
|
349 } |
|
350 |
|
351 // --------------------------------------------------------------------------- |
|
352 // Manages activity in a channel |
|
353 // --------------------------------------------------------------------------- |
|
354 // |
|
355 TInt CDunUpstream::ManageChannelActivity() |
|
356 { |
|
357 FTRACE(FPrint( _L("CDunUpstream::ManageChannelActivity()" ))); |
|
358 if ( iActivityData.iDataRead ) |
|
359 { |
|
360 FTRACE(FPrint( _L("CDunUpstream::ManageChannelActivity() (not ready) complete" ))); |
|
361 return KErrNotReady; |
|
362 } |
|
363 iActivityData.iDataRead = ETrue; |
|
364 if ( iActivityData.iActivityCallback && !iActivityData.iNotified ) |
|
365 { |
|
366 iActivityData.iActivityCallback->NotifyChannelActivity(); |
|
367 iActivityData.iNotified = ETrue; |
|
368 } |
|
369 FTRACE(FPrint( _L("CDunUpstream::ManageChannelActivity() complete" ))); |
|
370 return KErrNone; |
|
371 } |
|
372 |
|
373 // --------------------------------------------------------------------------- |
|
374 // From class CActive. |
|
375 // Gets called when endpoint data read/write complete |
|
376 // --------------------------------------------------------------------------- |
|
377 // |
|
378 void CDunUpstream::RunL() |
|
379 { |
|
380 FTRACE(FPrint( _L("CDunUpstream::RunL() (Dir=%d)" ), iDirection)); |
|
381 iTransferState = EDunStateIdle; |
|
382 |
|
383 TBool isError; |
|
384 TInt retTemp = iStatus.Int(); |
|
385 TInt stop = ProcessErrorCondition( retTemp, isError ); |
|
386 |
|
387 if ( !stop ) // no real error detected -> continue |
|
388 { |
|
389 TBool reIssue = ETrue; |
|
390 if ( !isError ) |
|
391 { |
|
392 if ( iOperationType == EDunOperationTypeRead ) |
|
393 { |
|
394 ManageChannelActivity(); |
|
395 reIssue = ProcessReadData(); |
|
396 } // if ( iOperationType == EDunOperationTypeRead ) |
|
397 else // iOperationType == EDunOperationTypeWrite |
|
398 { |
|
399 iOperationType = EDunOperationTypeRead; |
|
400 } |
|
401 } // if ( !isError ) |
|
402 |
|
403 if ( reIssue ) |
|
404 { |
|
405 IssueRequest(); |
|
406 } |
|
407 |
|
408 } // if ( !stop ) |
|
409 else // stop -> tear down connection |
|
410 { |
|
411 FTRACE(FPrint( _L("CDunUpstream::RunL() stop" ))); |
|
412 TDunConnectionReason connReason; |
|
413 connReason.iReasonType = EDunReasonTypeRW; |
|
414 connReason.iContext = GetMediaContext( EDunStreamTypeUpstream ); |
|
415 connReason.iSignalType = 0; |
|
416 connReason.iSignalHigh = EFalse; |
|
417 connReason.iDirection = iDirection; |
|
418 connReason.iErrorCode = retTemp; |
|
419 if ( iOperationType == EDunOperationTypeRead ) |
|
420 { |
|
421 iUtility->DoNotifyConnectionNotOk( iComm, |
|
422 iSocket, |
|
423 connReason, |
|
424 iCallbacksR ); |
|
425 } |
|
426 else // iOperationType == EDunOperationTypeWrite |
|
427 { |
|
428 iUtility->DoNotifyConnectionNotOk( iComm, |
|
429 iSocket, |
|
430 connReason, |
|
431 iCallbacksW ); |
|
432 } |
|
433 } // else |
|
434 |
|
435 FTRACE(FPrint( _L("CDunUpstream::RunL() complete" ))); |
|
436 } |
|
437 |
|
438 // --------------------------------------------------------------------------- |
|
439 // From class CActive. |
|
440 // Gets called on cancel |
|
441 // --------------------------------------------------------------------------- |
|
442 // |
|
443 void CDunUpstream::DoCancel() |
|
444 { |
|
445 } |
|
446 |
|
447 // --------------------------------------------------------------------------- |
|
448 // From class MDunAtCmdStatusReporter |
|
449 // Notifies about AT command handling start |
|
450 // --------------------------------------------------------------------------- |
|
451 // |
|
452 void CDunUpstream::NotifyAtCmdHandlingStart() |
|
453 { |
|
454 FTRACE(FPrint( _L("CDunUpstream::NotifyAtCmdHandlingStart()" ))); |
|
455 if ( iParseData.iHandling ) |
|
456 { |
|
457 FTRACE(FPrint( _L("CDunUpstream::NotifyAtCmdHandlingStart() (already set!)" ))); |
|
458 } |
|
459 iParseData.iHandling = ETrue; |
|
460 FTRACE(FPrint( _L("CDunUpstream::NotifyAtCmdHandlingStart() complete" ))); |
|
461 } |
|
462 |
|
463 // --------------------------------------------------------------------------- |
|
464 // From class MDunAtCmdStatusReporter |
|
465 // Notifies about AT command handling end |
|
466 // --------------------------------------------------------------------------- |
|
467 // |
|
468 void CDunUpstream::NotifyAtCmdHandlingEnd( TInt aStartIndex ) |
|
469 { |
|
470 FTRACE(FPrint( _L("CDunUpstream::NotifyAtCmdHandlingEnd()" ))); |
|
471 if ( !iParseData.iHandling ) |
|
472 { |
|
473 FTRACE(FPrint( _L("CDunUpstream::NotifyAtCmdHandlingEnd() (already set!)" ))); |
|
474 } |
|
475 iParseData.iHandling = EFalse; |
|
476 // Next check the offset to the next command inside this block |
|
477 TInt length = iBufferPtr->Length(); |
|
478 if ( aStartIndex < 0 ) |
|
479 { |
|
480 // Start of the next command not found so here we need to just reissue |
|
481 // the read request and not clear the input buffer. |
|
482 iParseData.iAtCmdHandler->SetEndOfCmdLine( EFalse ); |
|
483 IssueRequest(); // iOperationType must be read here (don't set) |
|
484 FTRACE(FPrint( _L("CDunUpstream::NotifyAtCmdHandlingEnd() (not found) complete" ))); |
|
485 return; |
|
486 } |
|
487 // Here the start of next command was found so try to directly handle that |
|
488 // command using ProcessReadData() for the next subblock. |
|
489 iParseData.iAtCmdHandler->SetEndOfCmdLine( ETrue ); |
|
490 TInt maxLength = iBufferPtr->MaxLength(); |
|
491 iBufferPtr->Set( &(*iBufferPtr)[aStartIndex], length-aStartIndex, maxLength ); |
|
492 TBool reIssue = ProcessReadData(); |
|
493 if ( reIssue ) |
|
494 { |
|
495 // Note: should come here only if something went wrong |
|
496 IssueRequest(); |
|
497 } |
|
498 FTRACE(FPrint( _L("CDunUpstream::NotifyAtCmdHandlingEnd() complete" ))); |
|
499 } |
|
500 |
|
501 // --------------------------------------------------------------------------- |
|
502 // From class MDunAtCmdStatusReporter |
|
503 // Notifies about editor mode reply |
|
504 // --------------------------------------------------------------------------- |
|
505 // |
|
506 void CDunUpstream::NotifyEditorModeReply( TBool aStart ) |
|
507 { |
|
508 FTRACE(FPrint( _L("CDunUpstream::NotifyEditorModeReply()" ))); |
|
509 if ( iParseData.iDataMode ) |
|
510 { |
|
511 FTRACE(FPrint( _L("CDunUpstream::NotifyEditorModeReply() (not ready) complete" ))); |
|
512 return; |
|
513 } |
|
514 // If start of editor mode then just reissue the read request |
|
515 // If continuation then echo and reissue the read request |
|
516 if ( aStart ) |
|
517 { |
|
518 IssueRequest(); |
|
519 FTRACE(FPrint( _L("CDunUpstream::NotifyEditorModeReply() (start) complete" ))); |
|
520 return; |
|
521 } |
|
522 iParseData.iAtCmdHandler->SendEchoCharacter( iBufferPtr, this ); |
|
523 FTRACE(FPrint( _L("CDunUpstream::NotifyEditorModeReply() complete" ))); |
|
524 } |
|
525 |
|
526 // --------------------------------------------------------------------------- |
|
527 // From class MDunAtCmdHandler |
|
528 // Starts URC message handling |
|
529 // --------------------------------------------------------------------------- |
|
530 // |
|
531 TInt CDunUpstream::StartUrc() |
|
532 { |
|
533 FTRACE(FPrint( _L("CDunUpstream::StartUrc()" ))); |
|
534 TInt retVal = KErrNone; |
|
535 if ( iParseData.iAtCmdHandler ) // optional |
|
536 { |
|
537 retVal = iParseData.iAtCmdHandler->StartUrc(); |
|
538 } |
|
539 FTRACE(FPrint( _L("CDunUpstream::StartUrc() complete" ))); |
|
540 return retVal; |
|
541 } |
|
542 |
|
543 // --------------------------------------------------------------------------- |
|
544 // From class MDunAtCmdHandler |
|
545 // Stops AT command handling downstream related activity (also URC) |
|
546 // --------------------------------------------------------------------------- |
|
547 // |
|
548 TInt CDunUpstream::StopAtCmdHandling() |
|
549 { |
|
550 FTRACE(FPrint( _L("CDunUpstream::StopAtCmdHandling()" ))); |
|
551 TInt retVal = KErrNone; |
|
552 if ( iParseData.iAtCmdHandler ) // optional |
|
553 { |
|
554 retVal = iParseData.iAtCmdHandler->StopUrc(); |
|
555 if ( retVal != KErrNone ) |
|
556 { |
|
557 iParseData.iAtCmdHandler->Stop(); |
|
558 FTRACE(FPrint( _L("CDunUpstream::StopAtCmdHandling() (iAtCmdHandler) complete" ))); |
|
559 return retVal; |
|
560 } |
|
561 retVal = iParseData.iAtCmdHandler->Stop(); |
|
562 } |
|
563 FTRACE(FPrint( _L("CDunUpstream::StopAtCmdHandling() complete" ))); |
|
564 return retVal; |
|
565 } |
|
566 |
|
567 // --------------------------------------------------------------------------- |
|
568 // From class MDunCmdModeMonitor. |
|
569 // Notifies about command mode start |
|
570 // --------------------------------------------------------------------------- |
|
571 // |
|
572 void CDunUpstream::NotifyCommandModeStart() |
|
573 { |
|
574 FTRACE(FPrint( _L("CDunUpstream::NotifyCommandModeStart()" ))); |
|
575 iParseData.iDataMode = EFalse; |
|
576 // Stop processing (just to be sure). |
|
577 // This will stop any possibly pending operations of |
|
578 // CDunAtCmdHandler and CDunAtUrcHandler. CDunDownstream will take care of |
|
579 // clearing (and stopping) non-callback write queues. |
|
580 StopAtCmdHandling(); |
|
581 // Also restart the URC handling after the data mode |
|
582 StartUrc(); |
|
583 FTRACE(FPrint( _L("CDunUpstream::NotifyCommandModeStart() complete" ))); |
|
584 } |
|
585 |
|
586 // --------------------------------------------------------------------------- |
|
587 // From class MDunCmdModeMonitor. |
|
588 // Notifies about command mode end |
|
589 // --------------------------------------------------------------------------- |
|
590 // |
|
591 void CDunUpstream::NotifyCommandModeEnd() |
|
592 { |
|
593 FTRACE(FPrint( _L("CDunUpstream::NotifyCommandModeEnd()" ))); |
|
594 iParseData.iDataMode = ETrue; |
|
595 // Stop processing (mandatory). |
|
596 // This will stop any possibly pending operations of |
|
597 // CDunAtCmdHandler and CDunAtUrcHandler. CDunDownstream will take care of |
|
598 // clearing (and stopping) non-callback write queues. |
|
599 StopAtCmdHandling(); |
|
600 // The follow is needed because stopping the AT command handling here |
|
601 // prevents the subsequent AT command handling notification to reach the |
|
602 // NotifyAtCmdHandlingEnd() in this class (the notification starts from |
|
603 // CDunAtCmdPusher's SetToIdleAndNotifyEnd()). |
|
604 // So here we have to do the block "if ( aStartIndex < 0 )" in function |
|
605 // NotifyAtCmdHandlingEnd(). |
|
606 IssueRequest(); |
|
607 FTRACE(FPrint( _L("CDunUpstream::NotifyCommandModeEnd() complete" ))); |
|
608 } |
|
609 |
|
610 // --------------------------------------------------------------------------- |
|
611 // From class MDunAtCmdEchoer. |
|
612 // Notifies about command mode end |
|
613 // --------------------------------------------------------------------------- |
|
614 // |
|
615 void CDunUpstream::NotifyEchoComplete() |
|
616 { |
|
617 FTRACE(FPrint( _L("CDunUpstream::NotifyEchoComplete()" ))); |
|
618 IssueRequest(); |
|
619 FTRACE(FPrint( _L("CDunUpstream::NotifyEchoComplete() complete" ))); |
|
620 } |