author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 15:32:36 +0300 | |
branch | RCL_3 |
changeset 44 | 7a45d2ea2f56 |
parent 40 | 52a167391590 |
permissions | -rw-r--r-- |
40 | 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 |
} |
|
44
7a45d2ea2f56
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
40
diff
changeset
|
124 |
// Note: the order of the added callbacks is important. When a mode change |
7a45d2ea2f56
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
40
diff
changeset
|
125 |
// occurs, it is best to do the most important stuff with the first callback |
7a45d2ea2f56
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
40
diff
changeset
|
126 |
// object and after this cleanups with the second. Example: Data mode start |
7a45d2ea2f56
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
40
diff
changeset
|
127 |
// should stop command handling; first callback stops command handling, |
7a45d2ea2f56
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
40
diff
changeset
|
128 |
// second callback stops multiplexer (doing this differently could cause the |
7a45d2ea2f56
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
40
diff
changeset
|
129 |
// multiplexer to re-activate). |
40 | 130 |
atCmdHandler->AddCmdModeCallback( aCallbackUp ); |
131 |
atCmdHandler->AddCmdModeCallback( aCallbackDown ); |
|
132 |
iParseData.iDataMode = EFalse; |
|
133 |
iParseData.iAtCmdHandler = atCmdHandler; |
|
134 |
FTRACE(FPrint( _L("CDunUpstream::InitializeForAtParsing() complete" ) )); |
|
135 |
return KErrNone; |
|
136 |
} |
|
137 |
||
138 |
// --------------------------------------------------------------------------- |
|
139 |
// Starts upstream by issuing read request |
|
140 |
// --------------------------------------------------------------------------- |
|
141 |
// |
|
142 |
TInt CDunUpstream::StartStream() |
|
143 |
{ |
|
144 |
FTRACE(FPrint( _L("CDunUpstream::StartStream()" ) )); |
|
145 |
if ( !iNetwork ) |
|
146 |
{ |
|
147 |
FTRACE(FPrint( _L("CDunUpstream::StartStream() (iNetwork) not initialized!" ) )); |
|
148 |
return KErrGeneral; |
|
149 |
} |
|
150 |
if ( !iComm && !iSocket ) |
|
151 |
{ |
|
152 |
FTRACE(FPrint( _L("CDunUpstream::StartStream() (iComm&iSocket) not initialized!" ) )); |
|
153 |
return KErrGeneral; |
|
154 |
} |
|
155 |
iOperationType = EDunOperationTypeRead; |
|
156 |
TInt retVal = IssueRequest(); |
|
157 |
FTRACE(FPrint( _L("CDunUpstream::StartStream() complete" ) )); |
|
158 |
return retVal; |
|
159 |
} |
|
160 |
||
161 |
// --------------------------------------------------------------------------- |
|
162 |
// Stops transfer for read or write endpoints |
|
163 |
// --------------------------------------------------------------------------- |
|
164 |
// |
|
165 |
TInt CDunUpstream::Stop() |
|
166 |
{ |
|
167 |
FTRACE(FPrint( _L("CDunUpstream::Stop() (Dir=%d)" ), iDirection)); |
|
168 |
// Don't stop CDunAtCmdHandler here as it is downstream related! |
|
169 |
if ( iTransferState != EDunStateTransferring ) |
|
170 |
{ |
|
171 |
FTRACE(FPrint( _L("CDunUpstream::Stop() (not ready) complete" ))); |
|
172 |
return KErrNotReady; |
|
173 |
} |
|
174 |
// Stop only current operation |
|
175 |
if ( iOperationType == EDunOperationTypeRead ) |
|
176 |
{ |
|
177 |
if ( iComm ) |
|
178 |
{ |
|
179 |
iComm->ReadCancel(); |
|
180 |
FTRACE(FPrint( _L("CDunUpstream::Stop() (RComm) cancelled" ))); |
|
181 |
} |
|
182 |
else if ( iSocket ) |
|
183 |
{ |
|
184 |
iSocket->CancelRecv(); |
|
185 |
FTRACE(FPrint( _L("CDunUpstream::Stop() (RSocket) cancelled" ))); |
|
186 |
} |
|
187 |
} |
|
188 |
else if ( iOperationType == EDunOperationTypeWrite ) |
|
189 |
{ |
|
190 |
if ( iNetwork ) |
|
191 |
{ |
|
192 |
iNetwork->WriteCancel(); |
|
193 |
FTRACE(FPrint( _L("CDunUpstream::Stop() (Network) cancelled" ))); |
|
194 |
} |
|
195 |
} |
|
196 |
Cancel(); |
|
197 |
iTransferState = EDunStateIdle; |
|
44
7a45d2ea2f56
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
40
diff
changeset
|
198 |
iOperationType = EDunOperationTypeUndefined; |
40 | 199 |
// Notify parent about inactivity |
200 |
if ( iActivityData.iActivityCallback && iActivityData.iNotified ) |
|
201 |
{ |
|
202 |
iActivityData.iActivityCallback->NotifyChannelInactivity(); |
|
203 |
iActivityData.iNotified = EFalse; |
|
204 |
} |
|
205 |
FTRACE(FPrint( _L("CDunUpstream::Stop() complete" ))); |
|
206 |
return KErrNone; |
|
207 |
} |
|
208 |
||
209 |
// --------------------------------------------------------------------------- |
|
210 |
// Data transmission state (if read completed) |
|
211 |
// --------------------------------------------------------------------------- |
|
212 |
// |
|
213 |
TBool CDunUpstream::DataReadStatus() |
|
214 |
{ |
|
215 |
return iActivityData.iDataRead; |
|
216 |
} |
|
217 |
||
218 |
// --------------------------------------------------------------------------- |
|
219 |
// CDunUpstream::CDunUpstream |
|
220 |
// --------------------------------------------------------------------------- |
|
221 |
// |
|
222 |
CDunUpstream::CDunUpstream( MDunTransporterUtilityAux* aUtility ) : |
|
223 |
iUtility( aUtility ) |
|
224 |
{ |
|
225 |
Initialize(); |
|
226 |
} |
|
227 |
||
228 |
// --------------------------------------------------------------------------- |
|
229 |
// CDunUpstream::ConstructL |
|
230 |
// --------------------------------------------------------------------------- |
|
231 |
// |
|
232 |
void CDunUpstream::ConstructL() |
|
233 |
{ |
|
234 |
FTRACE(FPrint( _L("CDunUpstream::ConstructL()" ) )); |
|
235 |
if ( !iUtility ) |
|
236 |
{ |
|
237 |
User::Leave( KErrGeneral ); |
|
238 |
} |
|
239 |
FTRACE(FPrint( _L("CDunUpstream::ConstructL() complete" ) )); |
|
240 |
} |
|
241 |
||
242 |
// --------------------------------------------------------------------------- |
|
243 |
// Initializes this class |
|
244 |
// --------------------------------------------------------------------------- |
|
245 |
// |
|
246 |
void CDunUpstream::Initialize() |
|
247 |
{ |
|
248 |
// Don't initialize iUtility here (it is set through NewL) |
|
249 |
iActivityData.iActivityCallback = NULL; |
|
250 |
iActivityData.iDataRead = EFalse; |
|
251 |
iActivityData.iNotified = EFalse; |
|
252 |
iParseData.iDataMode = EFalse; |
|
253 |
iParseData.iAtCmdHandler = NULL; |
|
254 |
} |
|
255 |
||
256 |
// --------------------------------------------------------------------------- |
|
257 |
// Issues transfer request for this stream |
|
258 |
// --------------------------------------------------------------------------- |
|
259 |
// |
|
260 |
TInt CDunUpstream::IssueRequest() |
|
261 |
{ |
|
262 |
// Set direction |
|
263 |
iDirection = static_cast<TDunDirection>( EDunStreamTypeUpstream | iOperationType ); |
|
264 |
||
265 |
FTRACE(FPrint( _L("CDunUpstream::IssueRequest() (Dir=%d)" ), iDirection)); |
|
266 |
||
267 |
if ( iTransferState != EDunStateIdle ) |
|
268 |
{ |
|
269 |
FTRACE(FPrint( _L("CDunUpstream::IssueRequest() (not ready) complete" ) )); |
|
270 |
return KErrNotReady; |
|
271 |
} |
|
272 |
||
273 |
if ( iOperationType == EDunOperationTypeRead ) |
|
274 |
{ |
|
275 |
iBufferPtr->SetLength( iBufferPtr->MaxLength() ); |
|
276 |
FTRACE(FPrint( _L("CDunUpstream::IssueRequest() trying to read %d bytes... (Dir=%d)" ), iBufferPtr->Length(), iDirection)); |
|
277 |
} |
|
278 |
else // iOperationType == EDunOperationTypeWrite |
|
279 |
{ |
|
280 |
FTRACE(FPrint( _L("CDunUpstream::IssueRequest() writing %d bytes... (Dir=%d)" ), iBufferPtr->Length(), iDirection)); |
|
281 |
} |
|
282 |
||
283 |
switch ( iDirection ) |
|
284 |
{ |
|
285 |
case EDunReaderUpstream: |
|
286 |
if ( iComm ) |
|
287 |
{ |
|
288 |
iStatus = KRequestPending; |
|
44
7a45d2ea2f56
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
40
diff
changeset
|
289 |
iTransferState = EDunStateTransferring; |
40 | 290 |
iComm->ReadOneOrMore( iStatus, *iBufferPtr ); |
44
7a45d2ea2f56
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
40
diff
changeset
|
291 |
SetActive(); |
40 | 292 |
FTRACE(FPrint( _L("CDunUpstream::IssueRequest() RComm ReadOneOrMore() requested" ) )); |
293 |
} |
|
294 |
else if ( iSocket ) |
|
295 |
{ |
|
296 |
iStatus = KRequestPending; |
|
44
7a45d2ea2f56
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
40
diff
changeset
|
297 |
iTransferState = EDunStateTransferring; |
40 | 298 |
iSocket->RecvOneOrMore( *iBufferPtr, 0, iStatus, iReadLengthSocket ); |
44
7a45d2ea2f56
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
40
diff
changeset
|
299 |
SetActive(); |
40 | 300 |
FTRACE(FPrint( _L("CDunUpstream::IssueRequest() RSocket RecvOneOrMore() requested" ) )); |
301 |
} |
|
302 |
else |
|
303 |
{ |
|
304 |
FTRACE(FPrint( _L("CDunUpstream::IssueRequest() (ERROR) complete" ) )); |
|
305 |
return KErrGeneral; |
|
306 |
} |
|
307 |
break; |
|
308 |
case EDunWriterUpstream: |
|
309 |
iStatus = KRequestPending; |
|
44
7a45d2ea2f56
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
40
diff
changeset
|
310 |
iTransferState = EDunStateTransferring; |
40 | 311 |
iNetwork->Write( iStatus, *iBufferPtr ); |
44
7a45d2ea2f56
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
40
diff
changeset
|
312 |
SetActive(); |
40 | 313 |
FTRACE(FPrint( _L("CDunUpstream::IssueRequest() RComm Write() requested" ) )); |
314 |
break; |
|
315 |
default: |
|
316 |
FTRACE(FPrint( _L("CDunUpstream::IssueRequest() (ERROR) complete" ) )); |
|
317 |
return KErrGeneral; |
|
318 |
} |
|
319 |
||
320 |
FTRACE(FPrint( _L("CDunUpstream::IssueRequest() (Dir=%d) complete" ), iDirection)); |
|
321 |
return KErrNone; |
|
322 |
} |
|
323 |
||
324 |
// --------------------------------------------------------------------------- |
|
325 |
// Processes data that was read |
|
326 |
// --------------------------------------------------------------------------- |
|
327 |
// |
|
328 |
TBool CDunUpstream::ProcessReadData() |
|
329 |
{ |
|
330 |
FTRACE(FPrint( _L("CDunUpstream::ProcessReadData()" ))); |
|
331 |
// The following will be transferred to Dataport |
|
332 |
if ( iParseData.iDataMode ) |
|
333 |
{ |
|
334 |
iOperationType = EDunOperationTypeWrite; |
|
335 |
FTRACE(FPrint( _L("CDunUpstream::ProcessReadData() (next write) complete" ))); |
|
336 |
return ETrue; |
|
337 |
} |
|
338 |
if ( !iParseData.iAtCmdHandler ) // optional |
|
339 |
{ |
|
340 |
FTRACE(FPrint( _L("CDunUpstream::ProcessReadData() (no handler) complete" ))); |
|
341 |
return ETrue; |
|
342 |
} |
|
343 |
// The following will be transferred to parser |
|
344 |
TInt retTemp = KErrNone; |
|
345 |
TBool moreNeeded = EFalse; |
|
346 |
retTemp = iParseData.iAtCmdHandler->AddDataForParsing( *iBufferPtr, |
|
347 |
moreNeeded ); |
|
348 |
if ( retTemp!=KErrNone || !moreNeeded ) |
|
349 |
{ |
|
350 |
// If error or no error but no more data needed, don't reissue |
|
351 |
FTRACE(FPrint( _L("CDunUpstream::ProcessReadData() (no reissue) complete" ))); |
|
352 |
return EFalse; |
|
353 |
} |
|
354 |
// If no error and more data needed, reissue |
|
355 |
FTRACE(FPrint( _L("CDunUpstream::ProcessReadData() (reissue) complete" ))); |
|
356 |
return ETrue; |
|
357 |
} |
|
358 |
||
359 |
// --------------------------------------------------------------------------- |
|
360 |
// Manages activity in a channel |
|
361 |
// --------------------------------------------------------------------------- |
|
362 |
// |
|
363 |
TInt CDunUpstream::ManageChannelActivity() |
|
364 |
{ |
|
365 |
FTRACE(FPrint( _L("CDunUpstream::ManageChannelActivity()" ))); |
|
366 |
if ( iActivityData.iDataRead ) |
|
367 |
{ |
|
368 |
FTRACE(FPrint( _L("CDunUpstream::ManageChannelActivity() (not ready) complete" ))); |
|
369 |
return KErrNotReady; |
|
370 |
} |
|
371 |
iActivityData.iDataRead = ETrue; |
|
372 |
if ( iActivityData.iActivityCallback && !iActivityData.iNotified ) |
|
373 |
{ |
|
374 |
iActivityData.iActivityCallback->NotifyChannelActivity(); |
|
375 |
iActivityData.iNotified = ETrue; |
|
376 |
} |
|
377 |
FTRACE(FPrint( _L("CDunUpstream::ManageChannelActivity() complete" ))); |
|
378 |
return KErrNone; |
|
379 |
} |
|
380 |
||
381 |
// --------------------------------------------------------------------------- |
|
382 |
// From class CActive. |
|
383 |
// Gets called when endpoint data read/write complete |
|
384 |
// --------------------------------------------------------------------------- |
|
385 |
// |
|
386 |
void CDunUpstream::RunL() |
|
387 |
{ |
|
388 |
FTRACE(FPrint( _L("CDunUpstream::RunL() (Dir=%d)" ), iDirection)); |
|
389 |
iTransferState = EDunStateIdle; |
|
390 |
||
391 |
TBool isError; |
|
392 |
TInt retTemp = iStatus.Int(); |
|
393 |
TInt stop = ProcessErrorCondition( retTemp, isError ); |
|
394 |
||
395 |
if ( !stop ) // no real error detected -> continue |
|
396 |
{ |
|
397 |
TBool reIssue = ETrue; |
|
398 |
if ( !isError ) |
|
399 |
{ |
|
400 |
if ( iOperationType == EDunOperationTypeRead ) |
|
401 |
{ |
|
402 |
ManageChannelActivity(); |
|
403 |
reIssue = ProcessReadData(); |
|
404 |
} // if ( iOperationType == EDunOperationTypeRead ) |
|
405 |
else // iOperationType == EDunOperationTypeWrite |
|
406 |
{ |
|
407 |
iOperationType = EDunOperationTypeRead; |
|
408 |
} |
|
409 |
} // if ( !isError ) |
|
410 |
||
411 |
if ( reIssue ) |
|
412 |
{ |
|
413 |
IssueRequest(); |
|
414 |
} |
|
415 |
||
416 |
} // if ( !stop ) |
|
417 |
else // stop -> tear down connection |
|
418 |
{ |
|
419 |
FTRACE(FPrint( _L("CDunUpstream::RunL() stop" ))); |
|
420 |
TDunConnectionReason connReason; |
|
421 |
connReason.iReasonType = EDunReasonTypeRW; |
|
422 |
connReason.iContext = GetMediaContext( EDunStreamTypeUpstream ); |
|
423 |
connReason.iSignalType = 0; |
|
424 |
connReason.iSignalHigh = EFalse; |
|
425 |
connReason.iDirection = iDirection; |
|
426 |
connReason.iErrorCode = retTemp; |
|
427 |
if ( iOperationType == EDunOperationTypeRead ) |
|
428 |
{ |
|
429 |
iUtility->DoNotifyConnectionNotOk( iComm, |
|
430 |
iSocket, |
|
431 |
connReason, |
|
432 |
iCallbacksR ); |
|
433 |
} |
|
434 |
else // iOperationType == EDunOperationTypeWrite |
|
435 |
{ |
|
436 |
iUtility->DoNotifyConnectionNotOk( iComm, |
|
437 |
iSocket, |
|
438 |
connReason, |
|
439 |
iCallbacksW ); |
|
440 |
} |
|
441 |
} // else |
|
442 |
||
443 |
FTRACE(FPrint( _L("CDunUpstream::RunL() complete" ))); |
|
444 |
} |
|
445 |
||
446 |
// --------------------------------------------------------------------------- |
|
447 |
// From class CActive. |
|
448 |
// Gets called on cancel |
|
449 |
// --------------------------------------------------------------------------- |
|
450 |
// |
|
451 |
void CDunUpstream::DoCancel() |
|
452 |
{ |
|
44
7a45d2ea2f56
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
40
diff
changeset
|
453 |
FTRACE(FPrint( _L("CDunUpstream::DoCancel()" ))); |
7a45d2ea2f56
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
40
diff
changeset
|
454 |
FTRACE(FPrint( _L("CDunUpstream::DoCancel() complete" ))); |
40 | 455 |
} |
456 |
||
457 |
// --------------------------------------------------------------------------- |
|
458 |
// From class MDunAtCmdStatusReporter |
|
459 |
// Notifies about parser's need to get more data |
|
460 |
// --------------------------------------------------------------------------- |
|
461 |
// |
|
462 |
void CDunUpstream::NotifyParserNeedsMoreData() |
|
463 |
{ |
|
464 |
FTRACE(FPrint( _L("CDunUpstream::NotifyParserNeedsMoreData()" ))); |
|
44
7a45d2ea2f56
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
40
diff
changeset
|
465 |
if ( iOperationType != EDunOperationTypeRead ) |
7a45d2ea2f56
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
40
diff
changeset
|
466 |
{ |
7a45d2ea2f56
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
40
diff
changeset
|
467 |
FTRACE(FPrint( _L("CDunUpstream::NotifyParserNeedsMoreData() (not ready) complete" ))); |
7a45d2ea2f56
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
40
diff
changeset
|
468 |
return; |
7a45d2ea2f56
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
40
diff
changeset
|
469 |
} |
40 | 470 |
IssueRequest(); // iOperationType must be read here (don't set) |
471 |
FTRACE(FPrint( _L("CDunUpstream::NotifyParserNeedsMoreData() complete" ))); |
|
472 |
} |
|
473 |
||
474 |
// --------------------------------------------------------------------------- |
|
475 |
// From class MDunAtCmdStatusReporter |
|
476 |
// Notifies about editor mode reply |
|
477 |
// --------------------------------------------------------------------------- |
|
478 |
// |
|
479 |
void CDunUpstream::NotifyEditorModeReply( TBool aStart ) |
|
480 |
{ |
|
481 |
FTRACE(FPrint( _L("CDunUpstream::NotifyEditorModeReply()" ))); |
|
482 |
if ( iParseData.iDataMode ) |
|
483 |
{ |
|
484 |
FTRACE(FPrint( _L("CDunUpstream::NotifyEditorModeReply() (not ready) complete" ))); |
|
485 |
return; |
|
486 |
} |
|
487 |
// If start of editor mode then just reissue the read request |
|
488 |
// If continuation then echo and reissue the read request |
|
489 |
if ( aStart ) |
|
490 |
{ |
|
491 |
IssueRequest(); |
|
492 |
FTRACE(FPrint( _L("CDunUpstream::NotifyEditorModeReply() (start) complete" ))); |
|
493 |
return; |
|
494 |
} |
|
495 |
iParseData.iAtCmdHandler->SendEchoCharacter( iBufferPtr, this ); |
|
496 |
FTRACE(FPrint( _L("CDunUpstream::NotifyEditorModeReply() complete" ))); |
|
497 |
} |
|
498 |
||
499 |
// --------------------------------------------------------------------------- |
|
500 |
// From class MDunAtCmdHandler |
|
501 |
// Starts URC message handling |
|
502 |
// --------------------------------------------------------------------------- |
|
503 |
// |
|
504 |
TInt CDunUpstream::StartUrc() |
|
505 |
{ |
|
506 |
FTRACE(FPrint( _L("CDunUpstream::StartUrc()" ))); |
|
507 |
TInt retVal = KErrNone; |
|
508 |
if ( iParseData.iAtCmdHandler ) // optional |
|
509 |
{ |
|
510 |
retVal = iParseData.iAtCmdHandler->StartUrc(); |
|
511 |
} |
|
512 |
FTRACE(FPrint( _L("CDunUpstream::StartUrc() complete" ))); |
|
513 |
return retVal; |
|
514 |
} |
|
515 |
||
516 |
// --------------------------------------------------------------------------- |
|
517 |
// From class MDunAtCmdHandler |
|
518 |
// Stops AT command handling downstream related activity (also URC) |
|
519 |
// --------------------------------------------------------------------------- |
|
520 |
// |
|
521 |
TInt CDunUpstream::StopAtCmdHandling() |
|
522 |
{ |
|
523 |
FTRACE(FPrint( _L("CDunUpstream::StopAtCmdHandling()" ))); |
|
524 |
TInt retVal = KErrNone; |
|
525 |
if ( iParseData.iAtCmdHandler ) // optional |
|
526 |
{ |
|
527 |
retVal = iParseData.iAtCmdHandler->StopUrc(); |
|
528 |
if ( retVal != KErrNone ) |
|
529 |
{ |
|
530 |
iParseData.iAtCmdHandler->Stop(); |
|
531 |
FTRACE(FPrint( _L("CDunUpstream::StopAtCmdHandling() (iAtCmdHandler) complete" ))); |
|
532 |
return retVal; |
|
533 |
} |
|
534 |
retVal = iParseData.iAtCmdHandler->Stop(); |
|
535 |
} |
|
536 |
FTRACE(FPrint( _L("CDunUpstream::StopAtCmdHandling() complete" ))); |
|
537 |
return retVal; |
|
538 |
} |
|
539 |
||
540 |
// --------------------------------------------------------------------------- |
|
541 |
// From class MDunCmdModeMonitor. |
|
542 |
// Notifies about command mode start |
|
543 |
// --------------------------------------------------------------------------- |
|
544 |
// |
|
545 |
void CDunUpstream::NotifyCommandModeStart() |
|
546 |
{ |
|
547 |
FTRACE(FPrint( _L("CDunUpstream::NotifyCommandModeStart()" ))); |
|
548 |
iParseData.iDataMode = EFalse; |
|
549 |
// Stop processing (just to be sure). |
|
550 |
// This will stop any possibly pending operations of |
|
551 |
// CDunAtCmdHandler and CDunAtUrcHandler. CDunDownstream will take care of |
|
552 |
// clearing (and stopping) non-callback write queues. |
|
553 |
StopAtCmdHandling(); |
|
554 |
// Also restart the URC handling after the data mode |
|
555 |
StartUrc(); |
|
556 |
FTRACE(FPrint( _L("CDunUpstream::NotifyCommandModeStart() complete" ))); |
|
557 |
} |
|
558 |
||
559 |
// --------------------------------------------------------------------------- |
|
560 |
// From class MDunCmdModeMonitor. |
|
561 |
// Notifies about command mode end |
|
562 |
// --------------------------------------------------------------------------- |
|
563 |
// |
|
564 |
void CDunUpstream::NotifyCommandModeEnd() |
|
565 |
{ |
|
566 |
FTRACE(FPrint( _L("CDunUpstream::NotifyCommandModeEnd()" ))); |
|
567 |
iParseData.iDataMode = ETrue; |
|
568 |
// Stop processing (mandatory). |
|
569 |
// This will stop any possibly pending operations of |
|
44
7a45d2ea2f56
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
40
diff
changeset
|
570 |
// CDunAtCmdHandler and CDunAtUrcHandler(s). CDunDownstream will take care |
7a45d2ea2f56
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
40
diff
changeset
|
571 |
// of clearing (and stopping) non-callback write queues. |
40 | 572 |
StopAtCmdHandling(); |
44
7a45d2ea2f56
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
40
diff
changeset
|
573 |
// The following is needed here because stopping the AT command handling |
7a45d2ea2f56
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
40
diff
changeset
|
574 |
// causes CDunAtCmdHandler not to call NotifyParserNeedsMoreData(). |
7a45d2ea2f56
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
40
diff
changeset
|
575 |
// In command mode iOperationType is always EDunOperationTypeRead. |
40 | 576 |
IssueRequest(); |
577 |
FTRACE(FPrint( _L("CDunUpstream::NotifyCommandModeEnd() complete" ))); |
|
578 |
} |
|
579 |
||
580 |
// --------------------------------------------------------------------------- |
|
581 |
// From class MDunAtCmdEchoer. |
|
582 |
// Notifies about command mode end |
|
583 |
// --------------------------------------------------------------------------- |
|
584 |
// |
|
585 |
void CDunUpstream::NotifyEchoComplete() |
|
586 |
{ |
|
587 |
FTRACE(FPrint( _L("CDunUpstream::NotifyEchoComplete()" ))); |
|
44
7a45d2ea2f56
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
40
diff
changeset
|
588 |
// iOperationType is always EDunOperationTypeRead here |
40 | 589 |
IssueRequest(); |
590 |
FTRACE(FPrint( _L("CDunUpstream::NotifyEchoComplete() complete" ))); |
|
591 |
} |