29
|
1 |
/*
|
|
2 |
* Copyright (c) 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: AT command pusher for downstream
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
/*
|
|
19 |
* Filtering categories for multiple commands on one line (DunAtCmdPusher.cpp)
|
|
20 |
* (here "OTHER" reply means a reply which is something else than "OK" and "ERROR")
|
|
21 |
* One reply: OK -> OK
|
|
22 |
* One reply: OTHER -> OTHER
|
|
23 |
* One reply: ERROR -> ERROR
|
|
24 |
* Two replies: OK, OK -> OK
|
|
25 |
* Two replies: OTHER, OTHER -> OTHER, OTHER
|
|
26 |
* Two replies: OK, OTHER -> OTHER
|
|
27 |
* Two replies: OTHER, OK -> OTHER
|
|
28 |
* Two replies: OK, ERROR -> ERROR
|
|
29 |
* Two replies: OTHER, ERROR -> OTHER, ERROR
|
|
30 |
* Note: "OK" replies are skipped. The "OK" string is stripped from the "OTHER"
|
|
31 |
* replies and manually added the the downstream as the last operation if either
|
|
32 |
* "OK" or "OTHER" was received before.
|
|
33 |
*/
|
|
34 |
|
|
35 |
#include "DunAtCmdPusher.h"
|
|
36 |
#include "DunDownstream.h"
|
|
37 |
#include "DunDebug.h"
|
|
38 |
|
|
39 |
// ---------------------------------------------------------------------------
|
|
40 |
// Two-phased constructor.
|
|
41 |
// ---------------------------------------------------------------------------
|
|
42 |
//
|
|
43 |
CDunAtCmdPusher* CDunAtCmdPusher::NewL(
|
|
44 |
RATExt* aAtCmdExt,
|
|
45 |
MDunAtCmdPusher* aCallback,
|
|
46 |
MDunStreamManipulator* aDownstream,
|
|
47 |
TDesC8* aOkBuffer )
|
|
48 |
{
|
|
49 |
CDunAtCmdPusher* self = NewLC( aAtCmdExt,
|
|
50 |
aCallback,
|
|
51 |
aDownstream,
|
|
52 |
aOkBuffer );
|
|
53 |
CleanupStack::Pop( self );
|
|
54 |
return self;
|
|
55 |
}
|
|
56 |
|
|
57 |
// ---------------------------------------------------------------------------
|
|
58 |
// Two-phased constructor.
|
|
59 |
// ---------------------------------------------------------------------------
|
|
60 |
//
|
|
61 |
CDunAtCmdPusher* CDunAtCmdPusher::NewLC(
|
|
62 |
RATExt* aAtCmdExt,
|
|
63 |
MDunAtCmdPusher* aCallback,
|
|
64 |
MDunStreamManipulator* aDownstream,
|
|
65 |
TDesC8* aOkBuffer )
|
|
66 |
{
|
|
67 |
CDunAtCmdPusher* self = new (ELeave) CDunAtCmdPusher( aAtCmdExt,
|
|
68 |
aCallback,
|
|
69 |
aDownstream,
|
|
70 |
aOkBuffer );
|
|
71 |
CleanupStack::PushL( self );
|
|
72 |
self->ConstructL();
|
|
73 |
return self;
|
|
74 |
}
|
|
75 |
|
|
76 |
// ---------------------------------------------------------------------------
|
|
77 |
// Destructor.
|
|
78 |
// ---------------------------------------------------------------------------
|
|
79 |
//
|
|
80 |
CDunAtCmdPusher::~CDunAtCmdPusher()
|
|
81 |
{
|
|
82 |
FTRACE(FPrint( _L("CDunAtCmdPusher::~CDunAtCmdPusher()") ));
|
|
83 |
ResetData();
|
|
84 |
FTRACE(FPrint( _L("CDunAtCmdPusher::~CDunAtCmdPusher() complete") ));
|
|
85 |
}
|
|
86 |
|
|
87 |
// ---------------------------------------------------------------------------
|
|
88 |
// Resets data to initial values
|
|
89 |
// ---------------------------------------------------------------------------
|
|
90 |
//
|
|
91 |
void CDunAtCmdPusher::ResetData()
|
|
92 |
{
|
|
93 |
FTRACE(FPrint( _L("CDunAtCmdPusher::ResetData()") ));
|
|
94 |
// APIs affecting this:
|
|
95 |
// IssueRequest()
|
|
96 |
Stop();
|
|
97 |
// Internal
|
|
98 |
Initialize();
|
|
99 |
FTRACE(FPrint( _L("CDunAtCmdPusher::ResetData() complete") ));
|
|
100 |
}
|
|
101 |
|
|
102 |
// ---------------------------------------------------------------------------
|
|
103 |
// Starts AT command handling
|
|
104 |
// ---------------------------------------------------------------------------
|
|
105 |
//
|
|
106 |
TInt CDunAtCmdPusher::IssueRequest( TDesC8& aInput, TBool aNormalMode )
|
|
107 |
{
|
|
108 |
FTRACE(FPrint( _L("CDunAtCmdPusher::IssueRequest()") ));
|
|
109 |
FTRACE(FPrint( _L("CDunAtCmdPusher::IssueRequest() send ATEXT:") ));
|
|
110 |
FTRACE(FPrintRaw(aInput) );
|
|
111 |
if ( iAtPushState!=EDunStateIdle && aNormalMode )
|
|
112 |
{
|
|
113 |
FTRACE(FPrint( _L("CDunAtCmdPusher::IssueRequest() (not ready) complete") ));
|
|
114 |
return KErrNotReady;
|
|
115 |
}
|
|
116 |
if ( iDownstream->IsDataInQueue(&iRecvBuffer) )
|
|
117 |
{
|
|
118 |
FTRACE(FPrint( _L("CDunAtCmdPusher::IssueRequest() (in queue!) complete") ));
|
|
119 |
return KErrGeneral;
|
|
120 |
}
|
|
121 |
iStatus = KRequestPending;
|
|
122 |
iAtCmdExt->HandleCommand( iStatus,
|
|
123 |
aInput,
|
|
124 |
iRecvBuffer,
|
|
125 |
iReplyLeftPckg,
|
|
126 |
iReplyTypePckg );
|
|
127 |
SetActive();
|
|
128 |
iAtPushState = EDunStateAtCmdPushing;
|
|
129 |
FTRACE(FPrint( _L("CDunAtCmdPusher::IssueRequest() complete") ));
|
|
130 |
return KErrNone;
|
|
131 |
}
|
|
132 |
|
|
133 |
// ---------------------------------------------------------------------------
|
|
134 |
// Stops AT command handling
|
|
135 |
// ---------------------------------------------------------------------------
|
|
136 |
//
|
|
137 |
TInt CDunAtCmdPusher::Stop()
|
|
138 |
{
|
|
139 |
FTRACE(FPrint( _L("CDunAtCmdPusher::Stop()") ));
|
|
140 |
SetEndOfCmdLine();
|
|
141 |
if ( iAtPushState != EDunStateAtCmdPushing )
|
|
142 |
{
|
|
143 |
FTRACE(FPrint( _L("CDunAtCmdHandler::Stop() (not ready) complete" )));
|
|
144 |
return KErrNotReady;
|
|
145 |
}
|
|
146 |
// As the EDunStateAtCmdHandling can be set even when the actual request
|
|
147 |
// has completed (when replying with NotifyDataPushComplete() and setting
|
|
148 |
// idle eventually), cancel the actual operation in DoCancel()
|
|
149 |
Cancel();
|
|
150 |
iAtPushState = EDunStateIdle;
|
|
151 |
FTRACE(FPrint( _L("CDunAtCmdPusher::Stop() complete") ));
|
|
152 |
return KErrNone;
|
|
153 |
}
|
|
154 |
|
|
155 |
// ---------------------------------------------------------------------------
|
|
156 |
// Manages request to abort command handling
|
|
157 |
// ---------------------------------------------------------------------------
|
|
158 |
//
|
|
159 |
TInt CDunAtCmdPusher::ManageAbortRequest()
|
|
160 |
{
|
|
161 |
FTRACE(FPrint( _L("CDunAtCmdPusher::ManageAbortRequest()") ));
|
|
162 |
if ( iAtPushState != EDunStateAtCmdPushing )
|
|
163 |
{
|
|
164 |
FTRACE(FPrint( _L("CDunAtCmdHandler::ManageAbortRequest() (not ready) complete" )));
|
|
165 |
return KErrNotReady;
|
|
166 |
}
|
|
167 |
if ( iCmdAbort )
|
|
168 |
{
|
|
169 |
FTRACE(FPrint( _L("CDunAtCmdPusher::ManageAbortRequest() (already exists) complete") ));
|
|
170 |
return KErrAlreadyExists;
|
|
171 |
}
|
|
172 |
TInt retTemp = iAtCmdExt->ReportHandleCommandAbort( iStop );
|
|
173 |
if ( retTemp != KErrNone )
|
|
174 |
{
|
|
175 |
FTRACE(FPrint( _L("CDunAtCmdPusher::ManageAbortRequest() (ERROR) complete") ));
|
|
176 |
return retTemp;
|
|
177 |
}
|
|
178 |
iCmdAbort = ETrue;
|
|
179 |
FTRACE(FPrint( _L("CDunAtCmdPusher::ManageAbortRequest() complete") ));
|
|
180 |
return KErrNone;
|
|
181 |
}
|
|
182 |
|
|
183 |
// ---------------------------------------------------------------------------
|
|
184 |
// Sets end of command line marker on for the possible series of AT commands.
|
|
185 |
// ---------------------------------------------------------------------------
|
|
186 |
//
|
|
187 |
void CDunAtCmdPusher::SetEndOfCmdLine()
|
|
188 |
{
|
|
189 |
FTRACE(FPrint( _L("CDunAtCmdPusher::SetEndOfCmdLine()") ));
|
|
190 |
iNoErrorReceived = EFalse;
|
|
191 |
iLastOkPush = EFalse;
|
|
192 |
iCmdAbort = EFalse;
|
|
193 |
iStop = EFalse;
|
|
194 |
iEditorMode = EFalse;
|
|
195 |
FTRACE(FPrint( _L("CDunAtCmdPusher::SetEndOfCmdLine() complete") ));
|
|
196 |
}
|
|
197 |
|
|
198 |
// ---------------------------------------------------------------------------
|
|
199 |
// Gets the editor mode status
|
|
200 |
// ---------------------------------------------------------------------------
|
|
201 |
//
|
|
202 |
TBool CDunAtCmdPusher::EditorMode()
|
|
203 |
{
|
|
204 |
FTRACE(FPrint( _L("CDunAtCmdPusher::EditorMode()") ));
|
|
205 |
FTRACE(FPrint( _L("CDunAtCmdPusher::EditorMode() complete") ));
|
|
206 |
return iEditorMode;
|
|
207 |
}
|
|
208 |
|
|
209 |
// ---------------------------------------------------------------------------
|
|
210 |
// CDunAtCmdPusher::CDunAtCmdPusher
|
|
211 |
// ---------------------------------------------------------------------------
|
|
212 |
//
|
|
213 |
CDunAtCmdPusher::CDunAtCmdPusher( RATExt* aAtCmdExt,
|
|
214 |
MDunAtCmdPusher* aCallback,
|
|
215 |
MDunStreamManipulator* aDownstream,
|
|
216 |
TDesC8* aOkBuffer ) :
|
|
217 |
CActive( EPriorityHigh ),
|
|
218 |
iAtCmdExt( aAtCmdExt ),
|
|
219 |
iCallback( aCallback ),
|
|
220 |
iDownstream( aDownstream ),
|
|
221 |
iOkBuffer( aOkBuffer ),
|
|
222 |
iReplyLeftPckg( iReplyBytesLeft ),
|
|
223 |
iReplyTypePckg( iReplyType )
|
|
224 |
{
|
|
225 |
Initialize();
|
|
226 |
}
|
|
227 |
|
|
228 |
// ---------------------------------------------------------------------------
|
|
229 |
// CDunAtCmdPusher::ConstructL
|
|
230 |
// ---------------------------------------------------------------------------
|
|
231 |
//
|
|
232 |
void CDunAtCmdPusher::ConstructL()
|
|
233 |
{
|
|
234 |
FTRACE(FPrint( _L("CDunAtCmdPusher::ConstructL()") ));
|
|
235 |
if ( !iAtCmdExt || !iCallback || !iDownstream || !iOkBuffer )
|
|
236 |
{
|
|
237 |
User::Leave( KErrGeneral );
|
|
238 |
}
|
|
239 |
CActiveScheduler::Add( this );
|
|
240 |
FTRACE(FPrint( _L("CDunAtCmdPusher::ConstructL() complete") ));
|
|
241 |
}
|
|
242 |
|
|
243 |
// ---------------------------------------------------------------------------
|
|
244 |
// Initializes this class
|
|
245 |
// ---------------------------------------------------------------------------
|
|
246 |
//
|
|
247 |
void CDunAtCmdPusher::Initialize()
|
|
248 |
{
|
|
249 |
// Don't initialize iAtCmdExt here (it is set through NewL)
|
|
250 |
// Don't initialize iCallback here (it is set through NewL)
|
|
251 |
// Don't initialize iDownstream here (it is set through NewL)
|
|
252 |
// Don't initialize iOkBuffer here (it is set through NewL)
|
|
253 |
iAtPushState = EDunStateIdle;
|
|
254 |
iReplyBytesLeft = 0;
|
|
255 |
iReplyType = EReplyTypeUndefined;
|
|
256 |
SetEndOfCmdLine();
|
|
257 |
}
|
|
258 |
|
|
259 |
// ---------------------------------------------------------------------------
|
|
260 |
// Sets state to idle and notifies about subcommand handling completion
|
|
261 |
// ---------------------------------------------------------------------------
|
|
262 |
//
|
|
263 |
void CDunAtCmdPusher::SetToIdleAndNotifyEnd( TInt aError )
|
|
264 |
{
|
|
265 |
FTRACE(FPrint( _L("CDunAtCmdPusher::SetToIdleAndNotifyEnd()") ));
|
|
266 |
iCmdAbort = EFalse;
|
|
267 |
iAtPushState = EDunStateIdle;
|
|
268 |
iCallback->NotifyEndOfProcessing( aError );
|
|
269 |
FTRACE(FPrint( _L("CDunAtCmdPusher::SetToIdleAndNotifyEnd() complete") ));
|
|
270 |
}
|
|
271 |
|
|
272 |
// ---------------------------------------------------------------------------
|
|
273 |
// Checks if "OK" (verbose) or "0" (numeric) string or exists at the end of
|
|
274 |
// buffer and removes it
|
|
275 |
// ---------------------------------------------------------------------------
|
|
276 |
//
|
|
277 |
TInt CDunAtCmdPusher::CheckAndRemoveOkString()
|
|
278 |
{
|
|
279 |
FTRACE(FPrint( _L("CDunAtCmdPusher::CheckAndRemoveOkString()") ));
|
|
280 |
TInt recvBufferLength = iRecvBuffer.Length();
|
|
281 |
TInt okBufferLength = iOkBuffer->Length();
|
|
282 |
// Skip the removal if removing not possible, if removal results in zero
|
|
283 |
// length (plugin should have used KErrReplyTypeOk) or if string to be
|
|
284 |
// removed is zero.
|
|
285 |
// Note also that if plugin sends a final reply when quiet mode is on, DUN
|
|
286 |
// can't remove the possibly existing result code as it is different from
|
|
287 |
// iOkReply (zero length).
|
|
288 |
if ( recvBufferLength<=okBufferLength || okBufferLength<=0 )
|
|
289 |
{
|
|
290 |
FTRACE(FPrint( _L("CDunAtCmdPusher::CheckAndRemoveOkString() (skip) complete") ));
|
|
291 |
return KErrGeneral;
|
|
292 |
}
|
|
293 |
TInt lengthWithNoOk = recvBufferLength - okBufferLength;
|
|
294 |
TPtr8 recvBufferDes( &iRecvBuffer[lengthWithNoOk], okBufferLength, okBufferLength );
|
|
295 |
if ( recvBufferDes.Compare(*iOkBuffer) != 0 )
|
|
296 |
{
|
|
297 |
FTRACE(FPrint( _L("CDunAtCmdPusher::CheckAndRemoveOkString() (not found) complete") ));
|
|
298 |
return KErrNotFound;
|
|
299 |
}
|
|
300 |
iRecvBuffer.SetLength( lengthWithNoOk );
|
|
301 |
FTRACE(FPrint( _L("CDunAtCmdPusher::CheckAndRemoveOkString() complete") ));
|
|
302 |
return KErrNone;
|
|
303 |
}
|
|
304 |
|
|
305 |
// ---------------------------------------------------------------------------
|
|
306 |
// Sends reply data to downstream
|
|
307 |
// ---------------------------------------------------------------------------
|
|
308 |
//
|
|
309 |
void CDunAtCmdPusher::SendReplyData( TBool aRecvBuffer )
|
|
310 |
{
|
|
311 |
FTRACE(FPrint( _L("CDunAtCmdPusher::SendReplyData()") ));
|
|
312 |
TDesC8* sendBuffer = iOkBuffer;
|
|
313 |
if ( aRecvBuffer )
|
|
314 |
{
|
|
315 |
sendBuffer = &iRecvBuffer;
|
|
316 |
// Check if last block of long push and remove "OK" if exists
|
|
317 |
if ( iReplyType==EReplyTypeOther && iReplyBytesLeft==0 )
|
|
318 |
{
|
|
319 |
CheckAndRemoveOkString();
|
|
320 |
}
|
|
321 |
}
|
|
322 |
FTRACE(FPrint( _L("CDunAtCmdPusher::SendReplyData() send reply:") ));
|
|
323 |
FTRACE(FPrintRaw(*sendBuffer) );
|
|
324 |
iDownstream->NotifyDataPushRequest( sendBuffer, this );
|
|
325 |
FTRACE(FPrint( _L("CDunAtCmdPusher::SendReplyData() complete") ));
|
|
326 |
}
|
|
327 |
|
|
328 |
// ---------------------------------------------------------------------------
|
|
329 |
// Manages change in reply type to EReplyTypeOther
|
|
330 |
// ---------------------------------------------------------------------------
|
|
331 |
//
|
|
332 |
void CDunAtCmdPusher::ManageReplyTypeChangeToOther()
|
|
333 |
{
|
|
334 |
FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChangeToOther()") ));
|
|
335 |
iNoErrorReceived = ETrue;
|
|
336 |
SendReplyData();
|
|
337 |
FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChangeToOther() complete") ));
|
|
338 |
}
|
|
339 |
|
|
340 |
// ---------------------------------------------------------------------------
|
|
341 |
// Manages change in reply type to EReplyTypeOk
|
|
342 |
// ---------------------------------------------------------------------------
|
|
343 |
//
|
|
344 |
void CDunAtCmdPusher::ManageReplyTypeChangeToOk()
|
|
345 |
{
|
|
346 |
FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChangeToOk()") ));
|
|
347 |
// Skip the "OK" replies if not last. Only push the "OK" reply at the end.
|
|
348 |
// iStop changes it so that the we have to send the "OK" immediately and
|
|
349 |
// only stop with NotifyDataPushComplete()
|
|
350 |
TBool found = iCallback->NotifyNextCommandPeekRequest();
|
|
351 |
if ( !found || iStop )
|
|
352 |
{
|
|
353 |
SendReplyData();
|
|
354 |
}
|
|
355 |
else
|
|
356 |
{
|
|
357 |
iNoErrorReceived = ETrue;
|
|
358 |
SetToIdleAndNotifyEnd( KErrNone );
|
|
359 |
}
|
|
360 |
FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChangeToOk() complete") ));
|
|
361 |
}
|
|
362 |
|
|
363 |
// ---------------------------------------------------------------------------
|
|
364 |
// Manages change in reply type to EReplyTypeError
|
|
365 |
// ---------------------------------------------------------------------------
|
|
366 |
//
|
|
367 |
void CDunAtCmdPusher::ManageReplyTypeChangeToError()
|
|
368 |
{
|
|
369 |
FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChangeToError()") ));
|
|
370 |
if ( iNoErrorReceived )
|
|
371 |
{
|
|
372 |
iAtCmdExt->ReportExternalHandleCommandError();
|
|
373 |
}
|
|
374 |
SendReplyData();
|
|
375 |
FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChangeToError() complete") ));
|
|
376 |
}
|
|
377 |
|
|
378 |
// ---------------------------------------------------------------------------
|
|
379 |
// Manages change in reply type to EReplyTypeEditor
|
|
380 |
// ---------------------------------------------------------------------------
|
|
381 |
//
|
|
382 |
void CDunAtCmdPusher::ManageReplyTypeChangeToEditor()
|
|
383 |
{
|
|
384 |
FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChangeToEditor()") ));
|
|
385 |
if ( !iEditorMode )
|
|
386 |
{
|
|
387 |
// First change to editor mode: manage it as EReplyTypeOther (prompt)
|
|
388 |
iEditorMode = ETrue;
|
|
389 |
ManageReplyTypeChangeToOther();
|
|
390 |
FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChangeToEditor() (editor) complete") ));
|
|
391 |
return;
|
|
392 |
}
|
|
393 |
// The same reply to editor mode as before: no reply, only notification for
|
|
394 |
// echo/forwarding purposes
|
|
395 |
iCallback->NotifyEditorModeReply();
|
|
396 |
// Do nothing after notifying. The next ForwardEditorModeInput() triggers
|
|
397 |
// the next call of this function.
|
|
398 |
FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChangeToEditor() complete") ));
|
|
399 |
}
|
|
400 |
|
|
401 |
// ---------------------------------------------------------------------------
|
|
402 |
// Manages change in reply type
|
|
403 |
// ---------------------------------------------------------------------------
|
|
404 |
//
|
|
405 |
void CDunAtCmdPusher::ManageReplyTypeChange()
|
|
406 |
{
|
|
407 |
FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChange()") ));
|
|
408 |
switch ( iReplyType )
|
|
409 |
{
|
|
410 |
case EReplyTypeOther:
|
|
411 |
{
|
|
412 |
FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChange() EReplyTypeOther") ));
|
|
413 |
iEditorMode = EFalse;
|
|
414 |
ManageReplyTypeChangeToOther();
|
|
415 |
}
|
|
416 |
break;
|
|
417 |
case EReplyTypeOk:
|
|
418 |
{
|
|
419 |
FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChange() EReplyTypeOk") ));
|
|
420 |
iEditorMode = EFalse;
|
|
421 |
ManageReplyTypeChangeToOk();
|
|
422 |
}
|
|
423 |
break;
|
|
424 |
case EReplyTypeError:
|
|
425 |
{
|
|
426 |
FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChange() EReplyTypeError") ));
|
|
427 |
iEditorMode = EFalse;
|
|
428 |
ManageReplyTypeChangeToError();
|
|
429 |
}
|
|
430 |
break;
|
|
431 |
case EReplyTypeEditor:
|
|
432 |
FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChange() EReplyTypeEditor") ));
|
|
433 |
ManageReplyTypeChangeToEditor();
|
|
434 |
break;
|
|
435 |
default:
|
|
436 |
{
|
|
437 |
FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChange() EReplyTypeUndefined") ));
|
|
438 |
iEditorMode = EFalse;
|
|
439 |
SetToIdleAndNotifyEnd( KErrNone );
|
|
440 |
}
|
|
441 |
break;
|
|
442 |
}
|
|
443 |
FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChange() complete") ));
|
|
444 |
}
|
|
445 |
|
|
446 |
// ---------------------------------------------------------------------------
|
|
447 |
// From class CActive.
|
|
448 |
// Gets called when AT command handled
|
|
449 |
// ---------------------------------------------------------------------------
|
|
450 |
//
|
|
451 |
void CDunAtCmdPusher::RunL()
|
|
452 |
{
|
|
453 |
FTRACE(FPrint( _L("CDunAtCmdPusher::RunL()") ));
|
|
454 |
TInt retTemp = iStatus.Int();
|
|
455 |
if ( retTemp != KErrNone )
|
|
456 |
{
|
|
457 |
SetToIdleAndNotifyEnd( retTemp );
|
|
458 |
FTRACE(FPrint( _L("CDunAtCmdPusher::RunL() (ERROR) complete (%d)"), retTemp));
|
|
459 |
return;
|
|
460 |
}
|
|
461 |
ManageReplyTypeChange();
|
|
462 |
FTRACE(FPrint( _L("CDunAtCmdPusher::RunL() complete") ));
|
|
463 |
}
|
|
464 |
|
|
465 |
// ---------------------------------------------------------------------------
|
|
466 |
// From class CActive.
|
|
467 |
// Gets called on cancel
|
|
468 |
// ---------------------------------------------------------------------------
|
|
469 |
//
|
|
470 |
void CDunAtCmdPusher::DoCancel()
|
|
471 |
{
|
|
472 |
FTRACE(FPrint( _L("CDunAtCmdPusher::DoCancel()") ));
|
|
473 |
iAtCmdExt->CancelHandleCommand();
|
|
474 |
FTRACE(FPrint( _L("CDunAtCmdPusher::DoCancel() complete") ));
|
|
475 |
}
|
|
476 |
|
|
477 |
// ---------------------------------------------------------------------------
|
|
478 |
// From class MDunCompletionReporter.
|
|
479 |
// Gets called when data push is complete
|
|
480 |
// ---------------------------------------------------------------------------
|
|
481 |
//
|
|
482 |
void CDunAtCmdPusher::NotifyDataPushComplete( TBool /*aAllPushed*/ )
|
|
483 |
{
|
|
484 |
FTRACE(FPrint( _L("CDunAtCmdPusher::NotifyDataPushComplete()") ));
|
|
485 |
// First check if error or stop condition detected
|
|
486 |
if ( iReplyType==EReplyTypeError || iStop )
|
|
487 |
{
|
|
488 |
SetEndOfCmdLine();
|
|
489 |
iAtPushState = EDunStateIdle;
|
|
490 |
iCallback->NotifyEndOfCmdLineProcessing();
|
|
491 |
FTRACE(FPrint( _L("CDunAtCmdPusher::NotifyDataPushComplete() (error reply) complete") ));
|
|
492 |
return;
|
|
493 |
}
|
|
494 |
// Secondly check only the case where push restart is required
|
|
495 |
if ( iReplyType==EReplyTypeOther && iReplyBytesLeft>0 )
|
|
496 |
{
|
|
497 |
iAtCmdExt->GetNextPartOfReply( iRecvBuffer, iReplyBytesLeft );
|
|
498 |
SendReplyData();
|
|
499 |
FTRACE(FPrint( _L("CDunAtCmdPusher::NotifyDataPushComplete() (push restart) complete") ));
|
|
500 |
return;
|
|
501 |
}
|
|
502 |
// Next check the case where other than "OK" and "ERROR" reply is received
|
|
503 |
// and that is the last one in the command line. Then just send "OK".
|
|
504 |
if ( !iLastOkPush && iReplyType==EReplyTypeOther )
|
|
505 |
{
|
|
506 |
TBool found = iCallback->NotifyNextCommandPeekRequest();
|
|
507 |
if ( !found )
|
|
508 |
{
|
|
509 |
// Force iReplyType here to match the correct one in NotifyDataPushComplete()
|
|
510 |
iReplyType = EReplyTypeOk;
|
|
511 |
iLastOkPush = ETrue;
|
|
512 |
SendReplyData( EFalse );
|
|
513 |
FTRACE(FPrint( _L("CDunAtCmdPusher::NotifyDataPushComplete() (last OK) complete") ));
|
|
514 |
return;
|
|
515 |
}
|
|
516 |
// Now the next command was found so just fall through
|
|
517 |
}
|
|
518 |
// As a last step just set to idle
|
|
519 |
SetToIdleAndNotifyEnd( KErrNone );
|
|
520 |
FTRACE(FPrint( _L("CDunAtCmdPusher::NotifyDataPushComplete() complete") ));
|
|
521 |
}
|