|
1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Dial Up States |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file Nd_dlupstates.cpp |
|
20 */ |
|
21 |
|
22 |
|
23 #include "Nd_dlupStates.h" |
|
24 #include "SLOGGER.H" |
|
25 #include <comms-infras/eventlogger.h> |
|
26 #include <csdprog.h> |
|
27 #include "ND_DBACC.H" |
|
28 |
|
29 |
|
30 CDlUpInit* CDlUpInit::NewL(MAgentStateMachineEnv& aSMObserver, MNetdialEnv& aNdEnv) |
|
31 /** |
|
32 Dial Up Init State |
|
33 |
|
34 2 phased constructor for CDlUpInit, first phase. |
|
35 |
|
36 @param aSMObserver a reference to state machine observer. |
|
37 @param aNdEnv a reference to the Netdial which defines a set of utility functions. |
|
38 @exception Leaves if ConstructL() leaves, or not enough memory is available. |
|
39 @return a new CDlUpInit object. |
|
40 */ |
|
41 { |
|
42 CDlUpInit* r=new(ELeave) CDlUpInit(aSMObserver, aNdEnv); |
|
43 CleanupStack::PushL(r); |
|
44 r->ConstructL(); |
|
45 CleanupStack::Pop(); |
|
46 return r; |
|
47 } |
|
48 |
|
49 CDlUpInit::CDlUpInit(MAgentStateMachineEnv& aSMObserver, MNetdialEnv& aNdEnv) |
|
50 : CAgentStateBase(aSMObserver),iNdEnv(&aNdEnv) |
|
51 /** |
|
52 Private constructor for CDlUpInit, used in the first phase of construction. |
|
53 |
|
54 @param aSMObserver a reference to the database accessor. |
|
55 @param aNdEnv a reference to the Netdial which defines a set of utility functions. |
|
56 */ |
|
57 {} |
|
58 |
|
59 void CDlUpInit::ConstructL() |
|
60 /** |
|
61 Instantiate Member variable. |
|
62 Call base class CNdCallBackStateBase::ConstructL(). |
|
63 |
|
64 @exception Leaves if CNdCallBackStateBase::ConstructL() leaves, or not enough memory is available. |
|
65 */ |
|
66 {} |
|
67 |
|
68 CDlUpInit::~CDlUpInit() |
|
69 /** |
|
70 Destructor. |
|
71 Cancel active request. |
|
72 */ |
|
73 { |
|
74 Cancel(); |
|
75 } |
|
76 |
|
77 void CDlUpInit::StartState() |
|
78 /** |
|
79 Starts dialup init state. |
|
80 If connection is reconnect and used script is not NULL, delete script. |
|
81 Call JumpToRunl() with KErrNone. |
|
82 */ |
|
83 { |
|
84 if (((iNdEnv->BaseEnv())->IsReconnect()) && (iNdEnv->Script()!=NULL)) |
|
85 { |
|
86 iNdEnv->DeleteScript(); |
|
87 } |
|
88 JumpToRunl(KErrNone); |
|
89 } |
|
90 |
|
91 CAgentStateBase* CDlUpInit::NextStateL(TBool aContinue) |
|
92 /** |
|
93 Changes to from init state to next state. |
|
94 If connection is not continued, create disconnect state. |
|
95 Else create dialling state. |
|
96 |
|
97 @exception Leaves if NewL() leaves. |
|
98 @return a new CDlUpDisconnect or CDlUpDialling object. |
|
99 */ |
|
100 { |
|
101 if(!aContinue) |
|
102 { |
|
103 return CDlUpDisconnect::NewL(*iSMObserver,*iNdEnv); |
|
104 } |
|
105 else |
|
106 { |
|
107 return CDlUpDialling::NewL(*iSMObserver,*iNdEnv); |
|
108 } |
|
109 } |
|
110 |
|
111 void CDlUpInit::DoCancel() |
|
112 /** |
|
113 Cancels active requests. |
|
114 */ |
|
115 { |
|
116 } |
|
117 |
|
118 void CDlUpInit::RunL() |
|
119 /** |
|
120 Dial up init completed. |
|
121 Call CompleteState() with KErrNone. |
|
122 */ |
|
123 { |
|
124 __ASSERT_DEBUG(iStatus==KErrNone, User::Invariant()); |
|
125 (iNdEnv->BaseEnv())->CompleteState(KErrNone); |
|
126 } |
|
127 |
|
128 CDlUpDialling* CDlUpDialling::NewL(MAgentStateMachineEnv& aSMObserver, MNetdialEnv& aNdEnv) |
|
129 /** |
|
130 Dial Up Dialling State |
|
131 |
|
132 2 phased constructor for CDlUpDialling, first phase. |
|
133 |
|
134 @param aSMObserver a reference to state machine observer. |
|
135 @param aNdEnv a reference to the Netdial which defines a set of utility functions. |
|
136 @exception Leaves if ConstructL() leaves, or not enough memory is available. |
|
137 @return a new CDlUpDialling object. |
|
138 */ |
|
139 { |
|
140 CDlUpDialling* r=new(ELeave) CDlUpDialling(aSMObserver,aNdEnv); |
|
141 CleanupStack::PushL(r); |
|
142 r->ConstructL(); |
|
143 CleanupStack::Pop(); |
|
144 return r; |
|
145 } |
|
146 |
|
147 CDlUpDialling::CDlUpDialling(MAgentStateMachineEnv& aSMObserver, MNetdialEnv& aNdEnv) |
|
148 : CAgentStateBase(aSMObserver),iNdEnv(&aNdEnv) |
|
149 /** |
|
150 Private constructor for CDlUpDialling, used in the first phase of construction. |
|
151 |
|
152 @param aSMObserver a reference to the database accessor. |
|
153 @param aNdEnv a reference to the Netdial which defines a set of utility functions. |
|
154 */ |
|
155 {} |
|
156 |
|
157 void CDlUpDialling::ConstructL() |
|
158 /** |
|
159 Instantiate Member variable. |
|
160 Call base class CNdCallBackStateBase::ConstructL(). |
|
161 |
|
162 @exception Leaves if CNdCallBackStateBase::ConstructL() leaves, or not enough memory is available. |
|
163 */ |
|
164 {} |
|
165 |
|
166 CDlUpDialling::~CDlUpDialling() |
|
167 /** |
|
168 Destructor. |
|
169 Cancel active request. |
|
170 */ |
|
171 { |
|
172 Cancel(); |
|
173 } |
|
174 |
|
175 void CDlUpDialling::StartState() |
|
176 /** |
|
177 Starts dialup dialling state. |
|
178 Call UpdateProgress() with EStartingDialling and KErrNone. |
|
179 If reconnect, trap and start reconnect by calling StartReconnectL() from ETel server processor. |
|
180 Else trap and start dial up by calling StartDialUpL() from ETel server processor. |
|
181 If trap error, call JumpToRunl() with the trap error and return. |
|
182 Else set state active. |
|
183 */ |
|
184 { |
|
185 TInt err=KErrNone; |
|
186 iSMObserver->UpdateProgress(ECsdStartingDialling,KErrNone); |
|
187 // Either start reconnection or dial up |
|
188 if ((iNdEnv->BaseEnv())->IsReconnect()) |
|
189 { |
|
190 TRAP(err,(iNdEnv->TelServPrc())->StartReconnectL(*this)); |
|
191 } |
|
192 else |
|
193 { |
|
194 TRAP(err,(iNdEnv->TelServPrc())->StartDialUpL(*this)); |
|
195 } |
|
196 // JumpToRunl with leave error if ETel server processor calls leave. |
|
197 if(err!=KErrNone) |
|
198 { |
|
199 JumpToRunl(err); |
|
200 return; |
|
201 } |
|
202 // Else continue connection, set state active and wait for completition. |
|
203 else |
|
204 { |
|
205 iStatus=KRequestPending; |
|
206 SetActive(); |
|
207 } |
|
208 } |
|
209 |
|
210 CAgentStateBase* CDlUpDialling::NextStateL(TBool aContinue) |
|
211 /** |
|
212 Changes to from dialling state to next state. |
|
213 If connection is not continued or iStatus is not KErrNone, create Disconnect state. |
|
214 Else create Open Data Port (BCA), Scan Script (non-BCA) state. |
|
215 |
|
216 @exception Leaves if NewL() leaves. |
|
217 @return a new CDlUpDisconnect or CDlUpOpenDataPort (BCA) / CDlUpScanScript (non-BCA) object. |
|
218 */ |
|
219 { |
|
220 if((!aContinue)||(iStatus!=KErrNone)) |
|
221 { |
|
222 return CDlUpDisconnect::NewL(*iSMObserver,*iNdEnv); |
|
223 } |
|
224 else |
|
225 { |
|
226 #ifdef SYMBIAN_NETWORKING_CSDAGENT_BCA_SUPPORT |
|
227 if (iNdEnv->UseScript()) |
|
228 { |
|
229 return CDlUpOpenDataPort::NewL(*iSMObserver, *iNdEnv); |
|
230 } |
|
231 else |
|
232 { |
|
233 return CDlUpOpen::NewL(*iSMObserver,*iNdEnv); |
|
234 } |
|
235 #else |
|
236 return CDlUpOpenDataPort::NewL(*iSMObserver, *iNdEnv); |
|
237 |
|
238 #endif |
|
239 } |
|
240 } |
|
241 |
|
242 void CDlUpDialling::TelFunctionComplete(TInt aError) |
|
243 { |
|
244 TRequestStatus* status=&iStatus; |
|
245 User::RequestComplete(status,aError); |
|
246 } |
|
247 |
|
248 void CDlUpDialling::DoCancel() |
|
249 /** |
|
250 Cancels active requests. |
|
251 */ |
|
252 { |
|
253 // if a log event creation is ongoing, we want to let it go and the log event should reflect the reality |
|
254 // a call has been made and custumer will be charged for it |
|
255 //iNdEnv->Logger()->Cancel(); |
|
256 if((iNdEnv->TelServPrc())!=NULL) |
|
257 (iNdEnv->TelServPrc())->Cancel(); |
|
258 if (iStatus == KRequestPending) |
|
259 { |
|
260 TelFunctionComplete(KErrCancel); |
|
261 } |
|
262 } |
|
263 |
|
264 void CDlUpDialling::RunL() |
|
265 /** |
|
266 Dialling completed (should not complete if connection cancelled). |
|
267 If there is an error then signal it by calling ConnectionComplete() with EFinishedDialling and iStatus.Int(). |
|
268 Call UpdateProgress() with ECsdFinishedDialling and KErrNone. |
|
269 Call PreventConnectionRetries() to stop new connections. |
|
270 Call CompleteState() with KErrNone. |
|
271 Dialling is always asynchronous, so should not complete if cancelled. |
|
272 */ |
|
273 { |
|
274 if(iStatus!=KErrNone) |
|
275 { |
|
276 __FLOG_STMT(_LIT(logString3,"Dialling");) |
|
277 __FLOG_STATIC2(KNetDialLogFolder(),KNetDialLogFile(),TRefByValue<const TDesC>(KCompletedPhaseLogString()), &logString3() ,iStatus.Int()); |
|
278 if (iNdEnv->Script()!=NULL) |
|
279 iNdEnv->Script()->CloseScript(); |
|
280 iSMObserver->ConnectionComplete(ECsdFinishedDialling,iStatus.Int()); |
|
281 return; |
|
282 } |
|
283 iSMObserver->UpdateProgress(ECsdFinishedDialling,KErrNone); |
|
284 iSMObserver->PreventConnectionRetries(); |
|
285 // request asynch creation of logevent and go to next state |
|
286 TBuf<KCommsDbSvrMaxFieldLength> remoteParty; |
|
287 (iNdEnv->NetDialDb())->GetRemoteParty(remoteParty); |
|
288 TDialString telNum; |
|
289 TRAPD(ret, (iNdEnv->NetDialDb())->DoDiallingResolutionL(telNum,EForDisplay)); |
|
290 #ifdef SYMBIAN_NETWORKING_CSDAGENT_BCA_SUPPORT |
|
291 iNdEnv->GetUseScriptL(); |
|
292 if (!iNdEnv->UseScript()) |
|
293 { |
|
294 // We need to do this stuff now because it will not be done later in the login script setup |
|
295 RCall::TCommPort commPort; |
|
296 iNdEnv->TelServPrc()->GetCommPortL(commPort); //This updates Nifman's record and is needed by ppp |
|
297 iSMObserver->ServiceStarted(); |
|
298 } |
|
299 #endif // SYMBIAN_NETWORKING_CSDAGENT_BCA_SUPPORT |
|
300 // JumpToRunl if error |
|
301 if(ret==KErrNone) |
|
302 { |
|
303 // no logging if problem in finding telephone number |
|
304 iNdEnv->Logger()->LogDataAddEvent(R_LOG_CON_CONNECTED, remoteParty,R_LOG_DIR_OUT,telNum,KLogDataEventTypeUid); |
|
305 } |
|
306 // go to next state without waiting for logevent creation being completed. |
|
307 (iNdEnv->BaseEnv())->CompleteState(KErrNone); |
|
308 } |
|
309 TInt CDlUpDialling::RunError(TInt aError) |
|
310 /** |
|
311 Handles errors |
|
312 */ |
|
313 { |
|
314 iSMObserver->ConnectionComplete(ECsdScannedScript,aError); |
|
315 return KErrNone; |
|
316 } |
|
317 |
|
318 CDlUpScanScript* CDlUpScanScript::NewL(MAgentStateMachineEnv& aSMObserver, MNetdialEnv& aNdEnv) |
|
319 /** |
|
320 Dial Up Scan Script State |
|
321 |
|
322 2 phased constructor for CDlUpScanScript, first phase. |
|
323 |
|
324 @param aSMObserver a reference to state machine observer. |
|
325 @param aNdEnv a reference to the Netdial which defines a set of utility functions. |
|
326 @exception Leaves if ConstructL() leaves, or not enough memory is available. |
|
327 @return a new CDlUpScanScript object. |
|
328 */ |
|
329 { |
|
330 CDlUpScanScript* r=new(ELeave) CDlUpScanScript(aSMObserver,aNdEnv); |
|
331 CleanupStack::PushL(r); |
|
332 r->ConstructL(); |
|
333 CleanupStack::Pop(); |
|
334 return r; |
|
335 } |
|
336 |
|
337 CDlUpScanScript::CDlUpScanScript(MAgentStateMachineEnv& aSMObserver, MNetdialEnv& aNdEnv) |
|
338 : CAgentStateBase(aSMObserver),iNdEnv(&aNdEnv) |
|
339 /** |
|
340 Private constructor for CDlUpDialling, used in the first phase of construction. |
|
341 |
|
342 @param aSMObserver a reference to the database accessor. |
|
343 @param aNdEnv a reference to the Netdial which defines a set of utility functions. |
|
344 */ |
|
345 {} |
|
346 |
|
347 void CDlUpScanScript::ConstructL() |
|
348 /** |
|
349 Instantiate Member variable. |
|
350 Call base class CNdCallBackStateBase::ConstructL(). |
|
351 |
|
352 @exception Leaves if CNdCallBackStateBase::ConstructL() leaves, or not enough memory is available. |
|
353 */ |
|
354 {} |
|
355 |
|
356 CDlUpScanScript::~CDlUpScanScript() |
|
357 /** |
|
358 Destructor. |
|
359 Cancel active request. |
|
360 */ |
|
361 { |
|
362 Cancel(); |
|
363 } |
|
364 |
|
365 void CDlUpScanScript::StartState() |
|
366 /** |
|
367 Starts Dialup Scan Script state, scans "login" script for READ command. |
|
368 Call UpdateProgress() with ECsdScanningScript and KErrNone. |
|
369 Setup script by calling SetUpScriptL(). |
|
370 If SetUpScriptL leaves, call JumpToRunl() with leave error. |
|
371 If script is used, start scannin script and set state active. |
|
372 Else call JumpToRunl() with KErrNone. |
|
373 */ |
|
374 { |
|
375 if (iNdEnv->UseScript()) |
|
376 { |
|
377 (iNdEnv->Script())->Scan(*this); |
|
378 iStatus=KRequestPending; |
|
379 SetActive(); |
|
380 } |
|
381 else |
|
382 { |
|
383 JumpToRunl(KErrNone); |
|
384 } |
|
385 } |
|
386 |
|
387 CAgentStateBase* CDlUpScanScript::NextStateL(TBool aContinue) |
|
388 /** |
|
389 Changes to from Scan Script state to next state. |
|
390 If connection is not continued or iStatus is not KErrNone, create Close Data Port (BCA) / Hangup (non-BCA) state. |
|
391 Else create get login info state. |
|
392 |
|
393 @exception Leaves if NewL() leaves. |
|
394 @return a new CDlUpCloseDataPort (BCA) / CDlUpHangUp (non-BCA) or CDlUpGetLoginInfo object. |
|
395 */ |
|
396 { |
|
397 if((!aContinue)||(iStatus!=KErrNone)) |
|
398 { |
|
399 return CDlUpCloseDataPort::NewL(*iSMObserver,*iNdEnv, iStatus.Int()); |
|
400 } |
|
401 else |
|
402 { |
|
403 return CDlUpGetLoginInfo::NewL(*iSMObserver,*iNdEnv); |
|
404 } |
|
405 } |
|
406 |
|
407 void CDlUpScanScript::DoCancel() |
|
408 /** |
|
409 Cancels active requests. |
|
410 */ |
|
411 { |
|
412 if (iNdEnv->Script()!=NULL) |
|
413 { |
|
414 (iNdEnv->Script())->Cancel(); |
|
415 } |
|
416 if (iStatus == KRequestPending) |
|
417 { |
|
418 ScriptFunctionComplete(KErrCancel); |
|
419 } |
|
420 } |
|
421 |
|
422 void CDlUpScanScript::RunL() |
|
423 /** |
|
424 Scan completed (should not complete if connection cancelled). |
|
425 If there is an error then signal it by calling ConnectionComplete() with EScannedScript and iStatus.Int(). |
|
426 Call UpdateProgress() with ECsdScannedScript and KErrNone. |
|
427 Call CompleteState() with KErrNone. |
|
428 */ |
|
429 { |
|
430 if(iStatus!=KErrNone) |
|
431 { |
|
432 __FLOG_STMT(_LIT(logString3,"Scan Script");) |
|
433 __FLOG_STATIC2(KNetDialLogFolder(),KNetDialLogFile(),TRefByValue<const TDesC>(KCompletedPhaseLogString()), &logString3(), iStatus.Int()); |
|
434 if (iNdEnv->Script()!=NULL) |
|
435 iNdEnv->Script()->CloseScript(); |
|
436 iSMObserver->ConnectionComplete(ECsdScannedScript,iStatus.Int()); |
|
437 return; |
|
438 } |
|
439 iSMObserver->UpdateProgress(ECsdScannedScript,KErrNone); |
|
440 (iNdEnv->BaseEnv())->CompleteState(KErrNone); |
|
441 } |
|
442 |
|
443 void CDlUpScanScript::ScriptFunctionComplete(TInt aError) |
|
444 { |
|
445 TRequestStatus* status=&iStatus; |
|
446 User::RequestComplete(status,aError); |
|
447 } |
|
448 |
|
449 CDlUpGetLoginInfo* CDlUpGetLoginInfo::NewL(MAgentStateMachineEnv& aSMObserver, MNetdialEnv& aNdEnv) |
|
450 /** |
|
451 Dial Up Get Login Info State |
|
452 |
|
453 2 phased constructor for CDlUpGetLoginInfo, first phase. |
|
454 |
|
455 @param aSMObserver a reference to state machine observer. |
|
456 @param aNdEnv a reference to the Netdial which defines a set of utility functions. |
|
457 @exception Leaves if ConstructL() leaves, or not enough memory is available. |
|
458 @return a new CDlUpGetLoginInfo object. |
|
459 */ |
|
460 { |
|
461 CDlUpGetLoginInfo* r=new(ELeave) CDlUpGetLoginInfo(aSMObserver,aNdEnv); |
|
462 CleanupStack::PushL(r); |
|
463 r->ConstructL(); |
|
464 CleanupStack::Pop(); |
|
465 return r; |
|
466 } |
|
467 |
|
468 CDlUpGetLoginInfo::CDlUpGetLoginInfo(MAgentStateMachineEnv& aSMObserver, MNetdialEnv& aNdEnv) |
|
469 : CGetLoginInfo(aSMObserver,aNdEnv) |
|
470 /** |
|
471 Private constructor for CDlUpGetLoginInfo, used in the first phase of construction. |
|
472 |
|
473 @param aSMObserver a reference to the database accessor. |
|
474 @param aNdEnv a reference to the Netdial which defines a set of utility functions. |
|
475 */ |
|
476 {} |
|
477 |
|
478 void CDlUpGetLoginInfo::ConstructL() |
|
479 /** |
|
480 Instantiate Member variable. |
|
481 */ |
|
482 {} |
|
483 |
|
484 CDlUpGetLoginInfo::~CDlUpGetLoginInfo() |
|
485 /** |
|
486 Destructor. |
|
487 |
|
488 Cancel active request. |
|
489 */ |
|
490 { |
|
491 } |
|
492 |
|
493 CAgentStateBase* CDlUpGetLoginInfo::NextStateL(TBool aContinue) |
|
494 /** |
|
495 Changes to from get login info state to next state. |
|
496 |
|
497 If connection is not continued or iStatus is not KErrNone, create Hangup state. |
|
498 Else create login state. |
|
499 |
|
500 @exception Leaves if NewL() leaves. |
|
501 @return a new CDlUpCloseDataPort (BCA) / CDlUpHangUp (non-BCA) or CDlUpLogin object. |
|
502 */ |
|
503 { |
|
504 if((!aContinue)||(iStatus!=KErrNone)) |
|
505 { |
|
506 __FLOG_STMT(_LIT(logString,"NetDial:\tGetLoginInfo state cancelling (aContinue %d, iStatus %d)");) |
|
507 __FLOG_STATIC2(KNetDialLogFolder(),KNetDialLogFile(),TRefByValue<const TDesC>(logString()), aContinue, iStatus.Int()); |
|
508 |
|
509 TInt err = iStatus.Int(); |
|
510 if (!aContinue && err == KErrNone) |
|
511 { |
|
512 // Ensure that CDlUpCloseDataPort receives an error in the case where aContinue==EFalse and iStatus==KErrNone. |
|
513 // If not, CDlUpCloseDataPort will carry on as if we are doing a normal startup, advance to CDlUpOpen, and cause |
|
514 // a NIFMAN panic (ConnectComplete(), state is EDisconnecting). Note that the aContinue flag does not seem to be |
|
515 // propagated between states, so even though it may be EFalse here (indicating a connection cancellation), in |
|
516 // CDlUpCloseDataPort it seems to revert back to ETrue. |
|
517 err = KErrCancel; |
|
518 } |
|
519 return CDlUpCloseDataPort::NewL(*iSMObserver,*iNdEnv, err); |
|
520 } |
|
521 else //succesful run of state |
|
522 { |
|
523 return CDlUpLogin::NewL(*iSMObserver,*iNdEnv); |
|
524 } |
|
525 } |
|
526 |
|
527 CDlUpLogin* CDlUpLogin::NewL(MAgentStateMachineEnv& aSMObserver, MNetdialEnv& aNdEnv) |
|
528 /** |
|
529 Dial Up Login State |
|
530 |
|
531 2 phased constructor for CDlUpLogin, first phase. |
|
532 |
|
533 @param aSMObserver a reference to state machine observer. |
|
534 @param aNdEnv a reference to the Netdial which defines a set of utility functions. |
|
535 @exception Leaves if ConstructL() leaves, or not enough memory is available. |
|
536 @return a new CDlUpLogin object. |
|
537 */ |
|
538 { |
|
539 CDlUpLogin* r=new(ELeave) CDlUpLogin(aSMObserver,aNdEnv); |
|
540 CleanupStack::PushL(r); |
|
541 r->ConstructL(); |
|
542 CleanupStack::Pop(); |
|
543 return r; |
|
544 } |
|
545 |
|
546 CDlUpLogin::CDlUpLogin(MAgentStateMachineEnv& aSMObserver, MNetdialEnv& aNdEnv) |
|
547 : CAgentStateBase(aSMObserver),iNdEnv(&aNdEnv) |
|
548 /** |
|
549 Private constructor for CDlUpLogin, used in the first phase of construction. |
|
550 |
|
551 @param aSMObserver a reference to the database accessor. |
|
552 @param aNdEnv a reference to the Netdial which defines a set of utility functions. |
|
553 */ |
|
554 {} |
|
555 |
|
556 void CDlUpLogin::ConstructL() |
|
557 /** |
|
558 Instantiate Member variable. |
|
559 */ |
|
560 {} |
|
561 |
|
562 CDlUpLogin::~CDlUpLogin() |
|
563 /** |
|
564 Destructor. |
|
565 Cancel active request. |
|
566 */ |
|
567 { |
|
568 Cancel(); |
|
569 } |
|
570 |
|
571 void CDlUpLogin::StartState() |
|
572 /** |
|
573 Starts dialup call login state. |
|
574 Call UpdateProgress() with ECsdStartingLogIn and KErrNone. |
|
575 Call DoStartStateL() and trap possible leave. |
|
576 If DoStartStateL leaves, call JumpToRunl() with leave error. |
|
577 */ |
|
578 { |
|
579 iSMObserver->UpdateProgress(ECsdStartingLogIn,KErrNone); |
|
580 // This call executes the actual script. |
|
581 TRAPD(ret,DoStartStateL()); |
|
582 if (ret!=KErrNone) |
|
583 JumpToRunl(ret); |
|
584 } |
|
585 |
|
586 void CDlUpLogin::DoStartStateL() |
|
587 /** |
|
588 If login script is valid then execute it. |
|
589 If script is used, call ExecuteL() and set state active. |
|
590 Else call JumpToRunl() with KErrNone. |
|
591 */ |
|
592 { |
|
593 if (iNdEnv->UseScript()) |
|
594 { |
|
595 (iNdEnv->Script())->ExecuteL(*this); |
|
596 iStatus=KRequestPending; |
|
597 SetActive(); |
|
598 } |
|
599 else |
|
600 { |
|
601 JumpToRunl(KErrNone); |
|
602 } |
|
603 } |
|
604 |
|
605 CAgentStateBase* CDlUpLogin::NextStateL(TBool aContinue) |
|
606 /** |
|
607 Changes to from login state to next state. |
|
608 If connection is not continued or iStatus is not KErrNone, create hangup state. |
|
609 Else create open state (non-BCA). Create close data port state (BCA). |
|
610 |
|
611 @exception Leaves if NewL() leaves. |
|
612 @return a new CDlUpCloseDataPort (BCA), CDlUpHangUp or CDlUpOpen (non-BCA) object. |
|
613 */ |
|
614 { |
|
615 (void)aContinue; |
|
616 return CDlUpCloseDataPort::NewL(*iSMObserver,*iNdEnv, iStatus.Int()); |
|
617 } |
|
618 |
|
619 void CDlUpLogin::ScriptFunctionComplete(TInt aError) |
|
620 { |
|
621 TRequestStatus* status=&iStatus; |
|
622 User::RequestComplete(status,aError); |
|
623 } |
|
624 |
|
625 void CDlUpLogin::DoCancel() |
|
626 /** |
|
627 Cancels active requests. |
|
628 */ |
|
629 { |
|
630 if(iNdEnv->Script()!=NULL) |
|
631 (iNdEnv->Script())->Cancel(); |
|
632 if (iStatus == KRequestPending) |
|
633 { |
|
634 ScriptFunctionComplete(KErrCancel); |
|
635 } |
|
636 } |
|
637 |
|
638 void CDlUpLogin::RunL() |
|
639 /** |
|
640 Login completed (should not complete if connection cancelled). |
|
641 If there is an error then signal it by calling ConnectionComplete() with ECsdFinishedLogIn and iStatus.Int(). |
|
642 Call UpdateProgress() with EScannedScript and KErrNone. |
|
643 Call CompleteState() with KErrNone. |
|
644 */ |
|
645 { |
|
646 if(iStatus!=KErrNone) |
|
647 { |
|
648 __FLOG_STMT(_LIT(logString3,"Login");) |
|
649 __FLOG_STATIC2(KNetDialLogFolder(),KNetDialLogFile(),TRefByValue<const TDesC>(KCompletedPhaseLogString()), &logString3(), iStatus.Int()); |
|
650 if (iNdEnv->Script()!=NULL) |
|
651 iNdEnv->Script()->CloseScript(); |
|
652 iSMObserver->ConnectionComplete(ECsdFinishedLogIn,iStatus.Int()); |
|
653 return; |
|
654 } |
|
655 |
|
656 iSMObserver->UpdateProgress(ECsdFinishedLogIn,KErrNone); |
|
657 (iNdEnv->BaseEnv())->CompleteState(KErrNone); |
|
658 } |
|
659 |
|
660 CDlUpOpen* CDlUpOpen::NewL(MAgentStateMachineEnv& aSMObserver, MNetdialEnv& aNdEnv) |
|
661 /** |
|
662 Dial Up Open State |
|
663 |
|
664 2 phased constructor for CDlUpOpen, first phase. |
|
665 |
|
666 @param aSMObserver a reference to state machine observer. |
|
667 @param aNdEnv a reference to the Netdial which defines a set of utility functions. |
|
668 @exception Leaves if ConstructL() leaves, or not enough memory is available. |
|
669 @return a new CDlUpOpen object. |
|
670 */ |
|
671 { |
|
672 CDlUpOpen* r=new(ELeave) CDlUpOpen(aSMObserver,aNdEnv); |
|
673 CleanupStack::PushL(r); |
|
674 r->ConstructL(); |
|
675 CleanupStack::Pop(); |
|
676 return r; |
|
677 } |
|
678 |
|
679 CDlUpOpen::CDlUpOpen(MAgentStateMachineEnv& aSMObserver, MNetdialEnv& aNdEnv) |
|
680 : CNdCallBackStateBase(aSMObserver),iNdEnv(&aNdEnv) |
|
681 /** |
|
682 Private constructor for CDlUpOpen, used in the first phase of construction. |
|
683 |
|
684 @param aSMObserver a reference to the database accessor. |
|
685 @param aNdEnv a reference to the Netdial which defines a set of utility functions. |
|
686 */ |
|
687 {} |
|
688 |
|
689 void CDlUpOpen::ConstructL() |
|
690 /** |
|
691 Instantiate Member variable. |
|
692 Call base class CNdCallBackStateBase::ConstructL(). |
|
693 |
|
694 @exception Leaves if CNdCallBackStateBase::ConstructL() leaves, or not enough memory is available. |
|
695 */ |
|
696 { |
|
697 CNdCallBackStateBase::ConstructL(); |
|
698 } |
|
699 |
|
700 CDlUpOpen::~CDlUpOpen() |
|
701 /** |
|
702 Destructor. |
|
703 Cancel active request. |
|
704 */ |
|
705 { |
|
706 Cancel(); |
|
707 } |
|
708 |
|
709 void CDlUpOpen::StartState() |
|
710 /** |
|
711 Starts dialup open state. |
|
712 Call JumpToRunl() with KErrNone. |
|
713 */ |
|
714 { |
|
715 JumpToRunl(KErrNone); |
|
716 } |
|
717 |
|
718 CAgentStateBase* CDlUpOpen::NextStateL(TBool /*aContinue*/) |
|
719 /** |
|
720 Changes to from open state to next state. |
|
721 If call back is used, create dial in init state. |
|
722 else if connection is reconnect, create dial up init state. |
|
723 Else create hangup state. |
|
724 |
|
725 @exception Leaves if NewL() leaves. |
|
726 @return a new CDlInInit, CDlUpInit or CDlUpHangUp object. |
|
727 */ |
|
728 { |
|
729 if((iNdEnv->BaseEnv())->CallBack()) |
|
730 { |
|
731 return CDlInInit::NewL(*iSMObserver,*iNdEnv); |
|
732 } |
|
733 else if((iNdEnv->BaseEnv())->IsReconnect()) |
|
734 { |
|
735 return CDlUpInit::NewL(*iSMObserver,*iNdEnv); |
|
736 } |
|
737 else |
|
738 { |
|
739 return CDlUpHangUp::NewL(*iSMObserver,*iNdEnv); |
|
740 } |
|
741 } |
|
742 #ifdef SYMBIAN_NETWORKING_CSDAGENT_BCA_SUPPORT |
|
743 void CDlUpOpen::TelFunctionComplete(TInt aError) |
|
744 { |
|
745 iTelEvent = ETrue; |
|
746 JumpToRunl(aError); |
|
747 } |
|
748 #endif |
|
749 |
|
750 void CDlUpOpen::DoCancel() |
|
751 /** |
|
752 Cancels active requests. |
|
753 */ |
|
754 { |
|
755 #ifdef SYMBIAN_NETWORKING_CSDAGENT_BCA_SUPPORT |
|
756 if(NULL != iNdEnv->TelServPrc()) |
|
757 { |
|
758 iNdEnv->TelServPrc()->Cancel(); |
|
759 } |
|
760 #endif |
|
761 // (iNdEnv->BaseEnv())->CompleteState(KErrCancel); |
|
762 } |
|
763 |
|
764 void CDlUpOpen::RunL() |
|
765 /** |
|
766 Open completed. |
|
767 Call UpdateProgress() with ECsdConnectionOpen and KErrNone. |
|
768 If script is used, close it. |
|
769 Call ConnectionComplete() with ECsdConnectionOpen and KErrNone. |
|
770 */ |
|
771 { |
|
772 #ifdef SYMBIAN_NETWORKING_CSDAGENT_BCA_SUPPORT |
|
773 if (iTelEvent) |
|
774 { |
|
775 iTelEvent = EFalse; |
|
776 iSMObserver->Notification(EAgentToNifEventTypeDisableConnection, |
|
777 reinterpret_cast<TAny*>(KErrDisconnected)); |
|
778 return; |
|
779 } |
|
780 #endif |
|
781 __ASSERT_DEBUG(iStatus==KErrNone,User::Invariant()); |
|
782 iSMObserver->UpdateProgress(ECsdConnectionOpen,KErrNone); |
|
783 __FLOG_STMT(_LIT8(logString,"NetDial:\tConnection Open");) |
|
784 __FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),logString()); |
|
785 if (iNdEnv->Script()!=NULL) |
|
786 iNdEnv->Script()->CloseScript(); |
|
787 iSMObserver->ConnectionComplete(ECsdConnectionOpen,KErrNone); |
|
788 #ifdef SYMBIAN_NETWORKING_CSDAGENT_BCA_SUPPORT |
|
789 iNdEnv->TelServPrc()->ListenForStatusChange(*this); |
|
790 #endif |
|
791 } |
|
792 |
|
793 CDlUpHangUp* CDlUpHangUp::NewL(MAgentStateMachineEnv& aSMObserver, MNetdialEnv& aNdEnv) |
|
794 /** |
|
795 Dial Up HangUp State |
|
796 |
|
797 2 phased constructor for CDlUpHangUp, first phase. |
|
798 |
|
799 @param aSMObserver a reference to state machine observer. |
|
800 @param aNdEnv a reference to the Netdial which defines a set of utility functions. |
|
801 @exception Leaves if ConstructL() leaves, or not enough memory is available. |
|
802 @return a new CDlUpHangUp object. |
|
803 */ |
|
804 { |
|
805 CDlUpHangUp* r=new(ELeave) CDlUpHangUp(aSMObserver,aNdEnv); |
|
806 CleanupStack::PushL(r); |
|
807 r->ConstructL(); |
|
808 CleanupStack::Pop(); |
|
809 return r; |
|
810 } |
|
811 |
|
812 CDlUpHangUp::CDlUpHangUp(MAgentStateMachineEnv& aSMObserver, MNetdialEnv& aNdEnv) |
|
813 : CNdCallBackStateBase(aSMObserver),iNdEnv(&aNdEnv) |
|
814 /** |
|
815 Private constructor for CDlUpHangUp, used in the first phase of construction. |
|
816 |
|
817 @param aSMObserver a reference to the database accessor. |
|
818 @param aNdEnv a reference to the Netdial which defines a set of utility functions. |
|
819 */ |
|
820 {} |
|
821 |
|
822 void CDlUpHangUp::ConstructL() |
|
823 /** |
|
824 Instantiate Member variable. |
|
825 Call base class CNdCallBackStateBase::ConstructL(). |
|
826 |
|
827 @exception Leaves if CNdCallBackStateBase::ConstructL() leaves, or not enough memory is available. |
|
828 */ |
|
829 { |
|
830 CNdCallBackStateBase::ConstructL(); |
|
831 } |
|
832 |
|
833 CDlUpHangUp::~CDlUpHangUp() |
|
834 /** |
|
835 Destructor. |
|
836 Cancel active request. |
|
837 */ |
|
838 { |
|
839 Cancel(); |
|
840 } |
|
841 |
|
842 void CDlUpHangUp::StartState() |
|
843 /** |
|
844 Starts dialup hangup state. |
|
845 Call UpdateProgress() with ECsdStartingHangUp and KErrNone. |
|
846 If script is used, clean up script. |
|
847 If dataport is loaned, recover it by calling ReturnCommPortL() from ETel server processor. |
|
848 If ReturnCommPortL leaves, call JumpToRunl() with the leave error and return. |
|
849 If call is active, call StartHangUpAfterDialOut() from ETel server processor and set state active. |
|
850 Else call JumpToRunl() with KErrNone. |
|
851 */ |
|
852 { |
|
853 iSMObserver->UpdateProgress(ECsdStartingHangUp,KErrNone); |
|
854 |
|
855 if (iNdEnv->Script()!=NULL) |
|
856 { |
|
857 (iNdEnv->Script())->CleanupScript(); |
|
858 } |
|
859 |
|
860 if (iNdEnv->TelServPrc()->CommPortLoaned()) |
|
861 { |
|
862 // returns ownership of the comm port to ETEL |
|
863 TRAPD(err,(iNdEnv->TelServPrc())->ReturnCommPortL()); |
|
864 if (err!=KErrNone) |
|
865 { |
|
866 JumpToRunl(err); |
|
867 return; |
|
868 } |
|
869 } |
|
870 |
|
871 if (iNdEnv->TelServPrc()->CallActive()) |
|
872 { |
|
873 (iNdEnv->TelServPrc())->StartHangUpAfterDialOut(*this); |
|
874 iStatus=KRequestPending; |
|
875 SetActive(); |
|
876 } |
|
877 else |
|
878 JumpToRunl(KErrNone); |
|
879 } |
|
880 |
|
881 CAgentStateBase* CDlUpHangUp::NextStateL(TBool /*aContinue*/) |
|
882 /** |
|
883 Changes to from hangup state to next state. |
|
884 Next State will always be Disconnect regardless of implementation results |
|
885 |
|
886 @exception Leaves if NewL() leaves. |
|
887 @return a new CDlUpDisconnect object. |
|
888 */ |
|
889 { |
|
890 return CDlUpDisconnect::NewL(*iSMObserver,*iNdEnv); |
|
891 } |
|
892 |
|
893 void CDlUpHangUp::TelFunctionComplete(TInt aError) |
|
894 { |
|
895 TRequestStatus* status=&iStatus; |
|
896 User::RequestComplete(status,aError); |
|
897 } |
|
898 |
|
899 void CDlUpHangUp::DoCancel() |
|
900 /** |
|
901 Cancels active requests. |
|
902 */ |
|
903 { |
|
904 (iNdEnv->TelServPrc())->Cancel(); |
|
905 if (iStatus == KRequestPending) |
|
906 { |
|
907 TelFunctionComplete(KErrCancel); |
|
908 } |
|
909 } |
|
910 |
|
911 void CDlUpHangUp::RunL() |
|
912 /** |
|
913 Hangup completed. |
|
914 If there is an error then log it, otherwise advance to closed phase. |
|
915 Else call UpdateProgress() with ECsdFinishedHangUp and KErrNone. |
|
916 Call CompleteState() with iStatus.Int(). |
|
917 */ |
|
918 { |
|
919 //update the log object |
|
920 iNdEnv->Logger()->LogDataUpdateEvent(R_LOG_CON_DISCONNECTED, KLogDataEventTypeUid); |
|
921 if(iStatus!=KErrNone) |
|
922 { |
|
923 #ifdef __FLOG_ACTIVE |
|
924 _LIT(logString3,"Hang Up"); |
|
925 _LIT8(logString2,"NetDial:\tDisconnection Error %d"); |
|
926 #endif |
|
927 __FLOG_STATIC2(KNetDialLogFolder(),KNetDialLogFile(),TRefByValue<const TDesC>(KCompletedPhaseLogString()), &logString3(), iStatus.Int()); |
|
928 __FLOG_STATIC1(KNetDialLogFolder(),KNetDialLogFile(),TRefByValue<const TDesC8>(logString2()), iStatus.Int()); |
|
929 } |
|
930 else |
|
931 { |
|
932 iSMObserver->UpdateProgress(ECsdFinishedHangUp,KErrNone); |
|
933 } |
|
934 (iNdEnv->BaseEnv())->CompleteState(iStatus.Int()); |
|
935 } |
|
936 |
|
937 CDlUpDisconnect* CDlUpDisconnect::NewL(MAgentStateMachineEnv& aSMObserver, MNetdialEnv& aNdEnv) |
|
938 /** |
|
939 Dial Up Disconnect State |
|
940 */ |
|
941 { |
|
942 CDlUpDisconnect* r=new(ELeave) CDlUpDisconnect(aSMObserver,aNdEnv); |
|
943 CleanupStack::PushL(r); |
|
944 r->ConstructL(); |
|
945 CleanupStack::Pop(); |
|
946 return r; |
|
947 } |
|
948 |
|
949 CDlUpDisconnect::CDlUpDisconnect(MAgentStateMachineEnv& aSMObserver, MNetdialEnv& aNdEnv) |
|
950 : CNdCallBackStateBase(aSMObserver),iNdEnv(&aNdEnv) |
|
951 /** |
|
952 Private constructor for CDlUpDisconnect, used in the first phase of construction. |
|
953 |
|
954 @param aSMObserver a reference to the database accessor. |
|
955 @param aNdEnv a reference to the Netdial which defines a set of utility functions. |
|
956 */ |
|
957 {} |
|
958 |
|
959 void CDlUpDisconnect::ConstructL() |
|
960 /** |
|
961 Instantiate Member variable. |
|
962 Call base class CNdCallBackStateBase::ConstructL(). |
|
963 |
|
964 @exception Leaves if CNdCallBackStateBase::ConstructL() leaves, or not enough memory is available. |
|
965 */ |
|
966 { |
|
967 CNdCallBackStateBase::ConstructL(); |
|
968 } |
|
969 |
|
970 CDlUpDisconnect::~CDlUpDisconnect() |
|
971 /** |
|
972 Destructor. |
|
973 Cancel active request. |
|
974 */ |
|
975 { |
|
976 Cancel(); |
|
977 } |
|
978 |
|
979 void CDlUpDisconnect::StartState() |
|
980 /** |
|
981 Starts dialup disconnect state. |
|
982 If script is used, clean up script. |
|
983 If ETel server processor is used, close all ETel call objects. |
|
984 Call JumpToRunl() with KErrNone. |
|
985 */ |
|
986 { |
|
987 if ((iNdEnv->Script())!=NULL) |
|
988 { |
|
989 (iNdEnv->Script())->CleanupScript(); |
|
990 } |
|
991 if ((iNdEnv->TelServPrc())!=NULL) |
|
992 { |
|
993 (iNdEnv->TelServPrc())->CloseCall(); |
|
994 } |
|
995 // We need to make sure that logging is finished before closing everything. |
|
996 // forward iStatus to the logger, which will be responsible to complete iStatus when it is finished. |
|
997 iStatus = KRequestPending; |
|
998 SetActive(); |
|
999 iNdEnv->Logger()->LogDataNotifyLastEventUpdate(&iStatus); |
|
1000 } |
|
1001 |
|
1002 CAgentStateBase* CDlUpDisconnect::NextStateL(TBool /*aContinue*/) |
|
1003 /** |
|
1004 Changes to from disconnect state to next state. |
|
1005 Next State will always be Disconnect regardless of implementation results. |
|
1006 |
|
1007 @exception Leaves if NewL() leaves. |
|
1008 @return a new CDlUpDisconnect object. |
|
1009 */ |
|
1010 { |
|
1011 return CDlUpDisconnect::NewL(*iSMObserver,*iNdEnv); |
|
1012 } |
|
1013 |
|
1014 void CDlUpDisconnect::DoCancel() |
|
1015 /** |
|
1016 Cancels active requests. |
|
1017 */ |
|
1018 { |
|
1019 } |
|
1020 |
|
1021 void CDlUpDisconnect::RunL() |
|
1022 /** |
|
1023 Disconnect completed. |
|
1024 Call DisconnectComplete(). |
|
1025 */ |
|
1026 { |
|
1027 __FLOG_STMT(_LIT8(logString,"NetDial:\tDisconnect Complete");) |
|
1028 __FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),logString()); |
|
1029 |
|
1030 iSMObserver->DisconnectComplete(); |
|
1031 } |
|
1032 |
|
1033 CDlUpOpenDataPort* CDlUpOpenDataPort::NewL(MAgentStateMachineEnv& aSMObserver, MNetdialEnv& aNdEnv) |
|
1034 /** |
|
1035 Dial Up Open Data Port State |
|
1036 */ |
|
1037 { |
|
1038 CDlUpOpenDataPort* r=new(ELeave) CDlUpOpenDataPort(aSMObserver,aNdEnv); |
|
1039 CleanupStack::PushL(r); |
|
1040 r->ConstructL(); |
|
1041 CleanupStack::Pop(); |
|
1042 return r; |
|
1043 } |
|
1044 |
|
1045 CDlUpOpenDataPort::CDlUpOpenDataPort(MAgentStateMachineEnv& aSMObserver, MNetdialEnv& aNdEnv) |
|
1046 : CAgentStateBase(aSMObserver),iNdEnv(&aNdEnv) |
|
1047 /** |
|
1048 Private constructor for CDlUpOpenDataPort, used in the first phase of construction. |
|
1049 |
|
1050 @param aSMObserver a reference to the database accessor. |
|
1051 @param aNdEnv a reference to the Netdial which defines a set of utility functions. |
|
1052 */ |
|
1053 {} |
|
1054 |
|
1055 void CDlUpOpenDataPort::ConstructL() |
|
1056 /** |
|
1057 Instantiate Member variable. |
|
1058 Call base class CNdCallBackStateBase::ConstructL(). |
|
1059 |
|
1060 @exception Leaves if CNdCallBackStateBase::ConstructL() leaves, or not enough memory is available. |
|
1061 */ |
|
1062 { |
|
1063 } |
|
1064 |
|
1065 CDlUpOpenDataPort::~CDlUpOpenDataPort() |
|
1066 /** |
|
1067 Destructor. |
|
1068 Cancel active request. |
|
1069 */ |
|
1070 { |
|
1071 Cancel(); |
|
1072 } |
|
1073 |
|
1074 void CDlUpOpenDataPort::StartState() |
|
1075 /** |
|
1076 Starts Dial Up Open Data Port state. |
|
1077 Set up script and initiate creation of channel. |
|
1078 Call JumpToRunl() with KErrNone. |
|
1079 */ |
|
1080 { |
|
1081 ASSERT(iNdEnv); |
|
1082 __FLOG_STMT(_LIT8(logString,"NetDial:\tOpening Data Port")); |
|
1083 __FLOG_STATIC(KNetDialLogFolder(), KNetDialLogFile(), logString()); |
|
1084 |
|
1085 iSMObserver->UpdateProgress(ECsdScanningScript,KErrNone); |
|
1086 TRAPD(ret,iNdEnv->SetUpScriptL()); |
|
1087 if (ret!=KErrNone) |
|
1088 { |
|
1089 JumpToRunl(ret); |
|
1090 return; |
|
1091 } |
|
1092 |
|
1093 iNdEnv->Script()->CreateChannel(iStatus); |
|
1094 iStatus = KRequestPending; |
|
1095 SetActive(); |
|
1096 } |
|
1097 |
|
1098 CAgentStateBase* CDlUpOpenDataPort::NextStateL(TBool aContinue) |
|
1099 /** |
|
1100 Changes to from Open Data Port state to next state. |
|
1101 Next State will be Hangup on errors or connection start cancellation, else Scan Script. |
|
1102 |
|
1103 @exception Leaves if NewL() leaves. |
|
1104 @return a new CDlUpHangUp or CDlUpOpenDataPort object. |
|
1105 */ |
|
1106 { |
|
1107 if((!aContinue)||(iStatus!=KErrNone)) |
|
1108 { |
|
1109 return CDlUpHangUp::NewL(*iSMObserver,*iNdEnv); |
|
1110 } |
|
1111 else |
|
1112 { |
|
1113 return CDlUpScanScript::NewL(*iSMObserver, *iNdEnv); |
|
1114 } |
|
1115 } |
|
1116 |
|
1117 void CDlUpOpenDataPort::DoCancel() |
|
1118 /** |
|
1119 Cancels active requests. |
|
1120 */ |
|
1121 { |
|
1122 iNdEnv->Script()->CancelCreateChannel(); |
|
1123 } |
|
1124 |
|
1125 void CDlUpOpenDataPort::RunL() |
|
1126 /** |
|
1127 Dial Up Open Data Port completed. |
|
1128 Call CompleteState() with KErrNone. |
|
1129 */ |
|
1130 { |
|
1131 if (iStatus!=KErrNone) |
|
1132 { |
|
1133 #ifdef __FLOG_ACTIVE |
|
1134 _LIT(logString3,"Open Data Port"); |
|
1135 #endif |
|
1136 __FLOG_STATIC2(KNetDialLogFolder(), KNetDialLogFile(), TRefByValue<const TDesC>(KCompletedPhaseLogString()), &logString3(), iStatus.Int()); |
|
1137 if (iNdEnv->Script()!=NULL) |
|
1138 iNdEnv->Script()->CloseScript(); |
|
1139 iSMObserver->ConnectionComplete(ECsdScannedScript,iStatus.Int()); |
|
1140 return; |
|
1141 } |
|
1142 |
|
1143 (iNdEnv->BaseEnv())->CompleteState(KErrNone); |
|
1144 } |
|
1145 |
|
1146 CDlUpCloseDataPort* CDlUpCloseDataPort::NewL(MAgentStateMachineEnv& aSMObserver, MNetdialEnv& aNdEnv, TInt aError) |
|
1147 /** |
|
1148 Dial Up Close Data Port State |
|
1149 */ |
|
1150 { |
|
1151 CDlUpCloseDataPort* r=new(ELeave) CDlUpCloseDataPort(aSMObserver,aNdEnv, aError); |
|
1152 CleanupStack::PushL(r); |
|
1153 r->ConstructL(); |
|
1154 CleanupStack::Pop(); |
|
1155 return r; |
|
1156 } |
|
1157 |
|
1158 CDlUpCloseDataPort::CDlUpCloseDataPort(MAgentStateMachineEnv& aSMObserver, MNetdialEnv& aNdEnv, TInt aError) |
|
1159 : CAgentStateBase(aSMObserver), iNdEnv(&aNdEnv), iError(aError) |
|
1160 /** |
|
1161 Private constructor for CDlUpCloseDataPort, used in the first phase of construction. |
|
1162 |
|
1163 @param aSMObserver a reference to the database accessor. |
|
1164 @param aNdEnv a reference to the Netdial which defines a set of utility functions. |
|
1165 */ |
|
1166 {} |
|
1167 |
|
1168 void CDlUpCloseDataPort::ConstructL() |
|
1169 /** |
|
1170 Instantiate Member variable. |
|
1171 Call base class CNdCallBackStateBase::ConstructL(). |
|
1172 |
|
1173 @exception Leaves if CNdCallBackStateBase::ConstructL() leaves, or not enough memory is available. |
|
1174 */ |
|
1175 { |
|
1176 } |
|
1177 |
|
1178 CDlUpCloseDataPort::~CDlUpCloseDataPort() |
|
1179 /** |
|
1180 Destructor. |
|
1181 Cancel active request. |
|
1182 */ |
|
1183 { |
|
1184 Cancel(); |
|
1185 } |
|
1186 |
|
1187 void CDlUpCloseDataPort::StartState() |
|
1188 /** |
|
1189 Starts Dial Up Close Data Port state. |
|
1190 Initiate shutdown of data port |
|
1191 */ |
|
1192 { |
|
1193 ASSERT(iNdEnv); |
|
1194 ASSERT (iNdEnv->Script()); |
|
1195 |
|
1196 __FLOG_STMT(_LIT8(logString,"NetDial:\tClosing Data Port")); |
|
1197 __FLOG_STATIC(KNetDialLogFolder(), KNetDialLogFile(), logString()); |
|
1198 |
|
1199 iNdEnv->Script()->ShutdownChannel(iStatus); |
|
1200 iStatus = KRequestPending; |
|
1201 SetActive(); |
|
1202 } |
|
1203 |
|
1204 CAgentStateBase* CDlUpCloseDataPort::NextStateL(TBool aContinue) |
|
1205 /** |
|
1206 Changes to from Close Data Port state to next state. |
|
1207 |
|
1208 @exception Leaves if NewL() leaves. |
|
1209 @return a new CDlUpCloseDataPort object. |
|
1210 */ |
|
1211 { |
|
1212 if((!aContinue) || (iError != KErrNone) || (iStatus.Int() != KErrNone)) |
|
1213 { |
|
1214 __FLOG_STMT(_LIT(logString,"NetDial:\tCloseDataPort state cancelling (iError %d, aContinue %d, iStatus %d)");) |
|
1215 __FLOG_STATIC3(KNetDialLogFolder(),KNetDialLogFile(),TRefByValue<const TDesC>(logString()), iError, aContinue, iStatus.Int()); |
|
1216 |
|
1217 return CDlUpHangUp::NewL(*iSMObserver,*iNdEnv); |
|
1218 } |
|
1219 else |
|
1220 { |
|
1221 return CDlUpOpen::NewL(*iSMObserver, *iNdEnv); |
|
1222 } |
|
1223 } |
|
1224 |
|
1225 void CDlUpCloseDataPort::DoCancel() |
|
1226 /** |
|
1227 Cancels active requests. |
|
1228 */ |
|
1229 { |
|
1230 } |
|
1231 |
|
1232 void CDlUpCloseDataPort::RunL() |
|
1233 /** |
|
1234 Close Data Port completed. |
|
1235 Call CompleteState() with KErrNone. |
|
1236 */ |
|
1237 { |
|
1238 // Note: we assume that if iError != KErrNone then ConnectionComplete() has already been called by |
|
1239 // the failing state (otherwise NIFMAN will panic due to the lack of a ConnectComplete() in response |
|
1240 // to its earlier Connect()). |
|
1241 if (iStatus!=KErrNone) |
|
1242 { |
|
1243 #ifdef __FLOG_ACTIVE |
|
1244 _LIT(logString3,"Close Data Port"); |
|
1245 _LIT8(logstring2,"Saved error = %d"); |
|
1246 #endif |
|
1247 __FLOG_STATIC2(KNetDialLogFolder(), KNetDialLogFile(), TRefByValue<const TDesC>(KCompletedPhaseLogString()), &logString3(), iStatus.Int()); |
|
1248 if (iError != KErrNone) |
|
1249 { |
|
1250 __FLOG_STATIC1(KNetDialLogFolder(), KNetDialLogFile(), TRefByValue<const TDesC8>(logstring2()), iError); |
|
1251 } |
|
1252 else |
|
1253 { |
|
1254 // Only do the ConnectionComplete() due to errors in this state if a previous state has not already done |
|
1255 // so (i.e. iError == KErrNone) otherwise NIFMAN will panic. |
|
1256 iSMObserver->ConnectionComplete(iStatus.Int()); |
|
1257 return; |
|
1258 } |
|
1259 } |
|
1260 (iNdEnv->BaseEnv())->CompleteState(KErrNone); |
|
1261 } |
|
1262 |