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 |
// NetDial State machine base class implementations
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
/**
|
|
19 |
@file Nd_bases.cpp
|
|
20 |
*/
|
|
21 |
|
|
22 |
#include "Nd_Bases.h"
|
|
23 |
#include "SLOGGER.H"
|
|
24 |
#include <comms-infras/eventlogger.h>
|
|
25 |
#include "ND_ETEL.H"
|
|
26 |
#include "ND_DBACC.H"
|
|
27 |
#include "ND_SCR.H"
|
|
28 |
|
|
29 |
// Netdial SM base class
|
|
30 |
|
|
31 |
CNetdialSM::CNetdialSM(MAgentNotify& aControllerObserver, CDialogProcessor* aDlgPrc, CCommsDbAccess& aDbAccess)
|
|
32 |
: CAgentSMBase(aControllerObserver,aDlgPrc,aDbAccess),
|
|
33 |
iNdScript(NULL)
|
|
34 |
/**
|
|
35 |
Constructor.
|
|
36 |
|
|
37 |
@param aControllerObserver a reference to the observer.
|
|
38 |
@param aDlgPrc a reference to the dialog processor.
|
|
39 |
@param aDbAccess a reference to the CommDB accessor
|
|
40 |
*/
|
|
41 |
{}
|
|
42 |
|
|
43 |
CNetdialSM::~CNetdialSM()
|
|
44 |
/**
|
|
45 |
Destructor.
|
|
46 |
Deletes objects used by Netdial Statemachine
|
|
47 |
*/
|
|
48 |
{
|
|
49 |
|
|
50 |
if(iNdScript)
|
|
51 |
{
|
|
52 |
delete iNdScript;
|
|
53 |
}
|
|
54 |
|
|
55 |
if(iLogger)
|
|
56 |
{
|
|
57 |
delete iLogger;
|
|
58 |
}
|
|
59 |
|
|
60 |
if(iTelServer)
|
|
61 |
{
|
|
62 |
delete iTelServer;
|
|
63 |
}
|
|
64 |
|
|
65 |
if(iDbAccess)
|
|
66 |
{
|
|
67 |
delete iDbAccess;
|
|
68 |
}
|
|
69 |
}
|
|
70 |
|
|
71 |
void CNetdialSM::ConstructL()
|
|
72 |
/**
|
|
73 |
2nd Phase of construction.
|
|
74 |
Instantiate Member variables.
|
|
75 |
*/
|
|
76 |
{
|
|
77 |
iDbAccess=CCommsDbNetDialAccess::NewL(iDb);
|
|
78 |
iTelServer=CTelServerProcessor::NewL(iDbAccess,EPriorityStandard);
|
|
79 |
iLogger=CEventLogger::NewL();
|
|
80 |
}
|
|
81 |
|
|
82 |
#ifdef SYMBIAN_NETWORKING_CSDAGENT_BCA_SUPPORT
|
|
83 |
void CNetdialSM::GetUseScriptL()
|
|
84 |
/**
|
|
85 |
Determine if a script needs to be used.
|
|
86 |
@see CNetdialSM::UseScript.
|
|
87 |
*/
|
|
88 |
{
|
|
89 |
TInt len = 0;
|
|
90 |
__FLOG_STMT(_LIT8(logString0,"Netdial:\tGetUseScriptL");)
|
|
91 |
__FLOG_STATIC(KNetDialLogFolder(), KNetDialLogFile(), logString0);
|
|
92 |
iDbAccess->GetScriptDetailsL(iUseScript, len);
|
|
93 |
__FLOG_STMT(_LIT8(logString1,"Netdial:\tGetUseScriptL. iUseScript [%d]");)
|
|
94 |
__FLOG_STATIC1(KNetDialLogFolder(), KNetDialLogFile(), logString1, iUseScript);
|
|
95 |
}
|
|
96 |
#endif // SYMBIAN_NETWORKING_CSDAGENT_BCA_SUPPORT
|
|
97 |
TInt CNetdialSM::GetExcessData(TDes8& aBuffer)
|
|
98 |
/**
|
|
99 |
Get excess data buffer from script engine.
|
|
100 |
|
|
101 |
@param aBuffer a reference to the observer.
|
|
102 |
@return KErrNotFound if script is not found.
|
|
103 |
*/
|
|
104 |
{
|
|
105 |
__FLOG_STMT(_LIT8(logString,"NetDial:\tGetting Excess Data");)
|
|
106 |
__FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),logString());
|
|
107 |
if (iNdScript!=NULL)
|
|
108 |
return iNdScript->GetExcessData(aBuffer);
|
|
109 |
else
|
|
110 |
{
|
|
111 |
aBuffer.Zero();
|
|
112 |
return KErrNotFound;
|
|
113 |
}
|
|
114 |
}
|
|
115 |
|
|
116 |
void CNetdialSM::DeleteScript()
|
|
117 |
/**
|
|
118 |
Deletes script.
|
|
119 |
*/
|
|
120 |
{
|
|
121 |
iNdScript->CleanupScript();
|
|
122 |
iNdScript->Cancel();
|
|
123 |
delete iNdScript;
|
|
124 |
iNdScript=NULL;
|
|
125 |
}
|
|
126 |
|
|
127 |
CGetLoginInfo::CGetLoginInfo(MAgentStateMachineEnv& aSMObserver, MNetdialEnv& aNdEnv)
|
|
128 |
: CAgentStateBase(aSMObserver),iNdEnv(&aNdEnv)
|
|
129 |
/**
|
|
130 |
Get Login Info State constructor.
|
|
131 |
|
|
132 |
@param aSMObserver a reference to the state machine observer.
|
|
133 |
@param aNdEnv a reference to the Netdial which defines a set of utility functions.
|
|
134 |
*/
|
|
135 |
{}
|
|
136 |
|
|
137 |
CGetLoginInfo::~CGetLoginInfo()
|
|
138 |
/**
|
|
139 |
Destructor.
|
|
140 |
Cancels active request.
|
|
141 |
*/
|
|
142 |
{
|
|
143 |
Cancel();
|
|
144 |
}
|
|
145 |
|
|
146 |
void CGetLoginInfo::StartState()
|
|
147 |
/**
|
|
148 |
Get login info from database or from user.
|
|
149 |
|
|
150 |
Updates current progress to the state machine observer, checks if the script is used
|
|
151 |
and requests login parameters. If there is no error, sets the state active to wait for
|
|
152 |
completition for login parameters. If script is not used, calls JumpToRunl to drive the
|
|
153 |
state forward.
|
|
154 |
*/
|
|
155 |
{
|
|
156 |
iSMObserver->UpdateProgress(ECsdGettingLoginInfo,KErrNone);
|
|
157 |
TInt ret=KErrNone;
|
|
158 |
if (iNdEnv->UseScript())
|
|
159 |
{
|
|
160 |
TBool res=EFalse;
|
|
161 |
TRAP(ret,res=iNdEnv->Script()->GetLoginParamsL(*this,iNdEnv->BaseEnv()->IsReconnect()));
|
|
162 |
if(ret==KErrNone && !res)
|
|
163 |
{
|
|
164 |
iStatus=KRequestPending;
|
|
165 |
SetActive();
|
|
166 |
return;
|
|
167 |
}
|
|
168 |
}
|
|
169 |
JumpToRunl(ret);
|
|
170 |
return;
|
|
171 |
}
|
|
172 |
|
|
173 |
void CGetLoginInfo::DoCancel()
|
|
174 |
/**
|
|
175 |
Cancel for active request.
|
|
176 |
If dialog processor is used, cancels it's requests.
|
|
177 |
If state is currently waiting for a request to be completed, calls ScriptFunctionComplete
|
|
178 |
with KErrCancel to cancel the request.
|
|
179 |
*/
|
|
180 |
{
|
|
181 |
if (iNdEnv->Script()!=NULL)
|
|
182 |
{
|
|
183 |
(iNdEnv->Script())->Cancel();
|
|
184 |
}
|
|
185 |
if ((iNdEnv->BaseEnv())->DlgPrc()!=NULL)
|
|
186 |
{
|
|
187 |
(iNdEnv->BaseEnv())->DlgPrc()->Cancel();
|
|
188 |
}
|
|
189 |
if (iStatus == KRequestPending)
|
|
190 |
{
|
|
191 |
ScriptFunctionComplete(KErrCancel);
|
|
192 |
}
|
|
193 |
}
|
|
194 |
|
|
195 |
void CGetLoginInfo::RunL()
|
|
196 |
/**
|
|
197 |
Getting login info completed (should not complete if connection cancelled)
|
|
198 |
If there is an error then signal it. Pass login name and password from user
|
|
199 |
to script executor, otherwise advance phase to and call ServiceStarted()
|
|
200 |
*/
|
|
201 |
{
|
|
202 |
if(iStatus!=KErrNone)
|
|
203 |
{
|
|
204 |
__FLOG_STMT(_LIT(logString3,"Get Login Info");)
|
|
205 |
__FLOG_STATIC2(KNetDialLogFolder(),KNetDialLogFile(),TRefByValue<const TDesC>(KCompletedPhaseLogString()), &logString3(), iStatus.Int());
|
|
206 |
if (iNdEnv->Script()!=NULL)
|
|
207 |
iNdEnv->Script()->CloseScript();
|
|
208 |
iSMObserver->ConnectionComplete(ECsdGotLoginInfo,iStatus.Int());
|
|
209 |
return;
|
|
210 |
}
|
|
211 |
iSMObserver->UpdateProgress(ECsdGotLoginInfo,KErrNone);
|
|
212 |
|
|
213 |
if (!(iNdEnv->BaseEnv())->IsReconnect())
|
|
214 |
{
|
|
215 |
__FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),KServiceStartedLogString());
|
|
216 |
}
|
|
217 |
else
|
|
218 |
{
|
|
219 |
__FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),KServiceStartedReconnLogString());
|
|
220 |
}
|
|
221 |
iSMObserver->ServiceStarted();
|
|
222 |
(iNdEnv->BaseEnv())->CompleteState(KErrNone);
|
|
223 |
}
|
|
224 |
|
|
225 |
void CGetLoginInfo::ScriptFunctionComplete(TInt aError)
|
|
226 |
/**
|
|
227 |
Completes script function with the aError parameter.
|
|
228 |
|
|
229 |
@param aError a error passed for completition.
|
|
230 |
*/
|
|
231 |
{
|
|
232 |
TRequestStatus* status=&iStatus;
|
|
233 |
User::RequestComplete(status,aError);
|
|
234 |
}
|
|
235 |
|
|
236 |
CEventLogger* MNetdialEnv::Logger()
|
|
237 |
/**
|
|
238 |
@internalComponent
|
|
239 |
*/
|
|
240 |
{ NetDialPanic(ELoggerNotDefined);return NULL; };
|
|
241 |
|
|
242 |
MAgentStateMachineEnv* CNetdialSM::BaseEnv()
|
|
243 |
{ return this; };
|
|
244 |
|
|
245 |
CCommsDbNetDialAccess* CNetdialSM::NetDialDb()
|
|
246 |
{ return iDbAccess; };
|
|
247 |
|
|
248 |
CNetDialScript* CNetdialSM::Script()
|
|
249 |
{ return iNdScript; };
|
|
250 |
|
|
251 |
CTelServerProcessor* CNetdialSM::TelServPrc()
|
|
252 |
{ return iTelServer; };
|
|
253 |
|
|
254 |
CEventLogger* CNetdialSM::Logger()
|
|
255 |
{ return iLogger; };
|
|
256 |
|
|
257 |
TBool CNetdialSM::UseScript() const
|
|
258 |
{ return iUseScript; }
|