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