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 |
// Dial Up State Machine
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
/**
|
|
19 |
@file Nd_dlup.cpp
|
|
20 |
*/
|
|
21 |
|
|
22 |
#include "ND_DLUP.H"
|
|
23 |
#include "ND_ETEL.H"
|
|
24 |
#include "ND_SCR.H"
|
|
25 |
#include <comms-infras/dialogprocessor.h>
|
|
26 |
#include <comms-infras/eventlogger.h>
|
|
27 |
#include "ND_DBACC.H"
|
|
28 |
#include "ND_STD.H"
|
|
29 |
#include "SLOGGER.H"
|
|
30 |
#include "Nd_dlupStates.h"
|
|
31 |
#include <comms-infras/nifprvar.h>
|
|
32 |
|
|
33 |
CDlUpAgXSM* CDlUpAgXSM::NewL(MAgentNotify& aObserver, CDialogProcessor* aDlgPrc, CCommsDbAccess& aDbAccess)
|
|
34 |
/**
|
|
35 |
Dial Up state machine
|
|
36 |
|
|
37 |
2 phased constructor, first phase.
|
|
38 |
|
|
39 |
@param aObserver a reference to state machine observer.
|
|
40 |
@param aDlgPrc a pointer to dialog processor.
|
|
41 |
@param aDbAccess a referecen to CommDB accessor
|
|
42 |
@exception Leaves if ConstructL() leaves, or not enough memory is available.
|
|
43 |
@return a new CDlUpAgXSM object.
|
|
44 |
*/
|
|
45 |
{
|
|
46 |
CDlUpAgXSM* r=new(ELeave) CDlUpAgXSM(aObserver,aDlgPrc,aDbAccess);
|
|
47 |
CleanupStack::PushL(r);
|
|
48 |
r->ConstructL();
|
|
49 |
CleanupStack::Pop();
|
|
50 |
return r;
|
|
51 |
}
|
|
52 |
|
|
53 |
CDlUpAgXSM::CDlUpAgXSM(MAgentNotify& aObserver, CDialogProcessor* aDlgPrc, CCommsDbAccess& aDbAccess)
|
|
54 |
: CNetdialSM(aObserver,aDlgPrc,aDbAccess)
|
|
55 |
/**
|
|
56 |
Private constructor used in the first phase of construction.
|
|
57 |
|
|
58 |
@param aObserver a reference to state machine observer.
|
|
59 |
@param aDlgPrc a pointer to the dialog processor.
|
|
60 |
@param aDbAccess a reference to the database accessor.
|
|
61 |
*/
|
|
62 |
{}
|
|
63 |
|
|
64 |
CDlUpAgXSM::~CDlUpAgXSM()
|
|
65 |
/**
|
|
66 |
Destructor. Cancels active requests.
|
|
67 |
*/
|
|
68 |
{
|
|
69 |
Cancel();
|
|
70 |
}
|
|
71 |
|
|
72 |
void CDlUpAgXSM::ConstructL()
|
|
73 |
/**
|
|
74 |
Private constructor used in the first phase of construction.
|
|
75 |
Calls base call constructor CNetdialSM::ConstructL() and calls CDlUpInit::NewL().
|
|
76 |
|
|
77 |
@exception Leaves if CNetdialSM::ConstructL() or dial up init state creation leaves.
|
|
78 |
*/
|
|
79 |
{
|
|
80 |
CNetdialSM::ConstructL();
|
|
81 |
//Start off the state machine by instantiating an Initial state
|
|
82 |
//which contains little functionality
|
|
83 |
iState=CDlUpInit::NewL(*this,*this);
|
|
84 |
}
|
|
85 |
|
|
86 |
void CDlUpAgXSM::SetUpScriptL()
|
|
87 |
/**
|
|
88 |
Setups scripts for dialup connection
|
|
89 |
Loans dataport from ETel server.
|
|
90 |
Gets script details from CommDB accessor by calling GetScriptDetailsL().
|
|
91 |
If script is not used, sets iUseScript to EFalse.
|
|
92 |
Creates CNetDialScript.
|
|
93 |
|
|
94 |
@exception Leaves if GetCommPortL(), GetScriptDetailsL() or NewL() leaves.
|
|
95 |
*/
|
|
96 |
{
|
|
97 |
RCall::TCommPort commPort;
|
|
98 |
iTelServer->GetCommPortL(commPort);
|
|
99 |
TCommRole role;
|
|
100 |
iDbAccess->GetCommPortRoleL(role);
|
|
101 |
TInt len;
|
|
102 |
iDbAccess->GetScriptDetailsL(iUseScript,len);
|
|
103 |
if (!iUseScript || len==0)
|
|
104 |
{ // set them consistently
|
|
105 |
iUseScript=EFalse;
|
|
106 |
}
|
|
107 |
iNdScript=CNetDialScript::NewL(iDbAccess,iDlgPrc,commPort,role,len); // create it whatever because we need other stuff
|
|
108 |
}
|
|
109 |
|
|
110 |
TInt CDlUpAgXSM::Notification(TNifToAgentEventType aEvent, TAny* /*aInfo*/)
|
|
111 |
/**
|
|
112 |
Act on / reply to NifMan's notification requests
|
|
113 |
*/
|
|
114 |
{
|
|
115 |
switch (aEvent)
|
|
116 |
{
|
|
117 |
case ENifToAgentEventTypePPPCallbackGranted:
|
|
118 |
{
|
|
119 |
__FLOG_STMT(_LIT8(logString,"NetDial:\tCallback Request Granted");)
|
|
120 |
__FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),logString());
|
|
121 |
return KErrNone;
|
|
122 |
}
|
|
123 |
case ENifToAgentEventTypeQueryIsDialIn:
|
|
124 |
{
|
|
125 |
if(iCallBack)
|
|
126 |
{
|
|
127 |
return ENDDialTypeCallBackDialIn;
|
|
128 |
}
|
|
129 |
else
|
|
130 |
{
|
|
131 |
return ENDDialTypeDialOut;
|
|
132 |
}
|
|
133 |
}
|
|
134 |
case ENifToAgentEventTypeLinkLayerDown:
|
|
135 |
{
|
|
136 |
// stop the logging, the connection has been dropped
|
|
137 |
Logger()->LogDataUpdateEvent(R_LOG_CON_DISCONNECTED, KLogDataEventTypeUid);
|
|
138 |
// does nothing if logging not started
|
|
139 |
return KErrNone;
|
|
140 |
}
|
|
141 |
default:
|
|
142 |
return KErrNone;
|
|
143 |
}
|
|
144 |
}
|
|
145 |
|
|
146 |
TInt CDlUpAgXSM::IncomingConnectionReceived()
|
|
147 |
/**
|
|
148 |
Incoming connection is not supported in dial up.
|
|
149 |
*/
|
|
150 |
{
|
|
151 |
return KErrNotSupported;
|
|
152 |
}
|