24
|
1 |
// Copyright (c) 1997-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 |
//
|
|
15 |
|
|
16 |
#include <commsdattypesv1_1.h>
|
|
17 |
#include "ATCONNCT.H"
|
|
18 |
#include "mSLOGGER.H"
|
|
19 |
#include "PHONE.H"
|
|
20 |
#include "CALL.H"
|
|
21 |
#include "ATNOCARR.H"
|
|
22 |
#include "NOTIFY.H"
|
|
23 |
#include "ATIO.H"
|
|
24 |
|
|
25 |
//
|
|
26 |
// Connect to already dialled call
|
|
27 |
//
|
|
28 |
CATConnectData* CATConnectData::NewL(CATIO* aIo, CTelObject* aTelObject,CATInit* aInit,CPhoneGlobals* aPhoneGlobals)
|
|
29 |
{
|
|
30 |
CATConnectData* connect=new(ELeave) CATConnectData(aIo, aTelObject, aInit,aPhoneGlobals);
|
|
31 |
CleanupStack::PushL(connect);
|
|
32 |
connect->ConstructL();
|
|
33 |
CleanupStack::Pop();
|
|
34 |
return connect;
|
|
35 |
}
|
|
36 |
|
|
37 |
CATConnectData::CATConnectData(CATIO* aIo, CTelObject* aTelObject,CATInit* aInit,CPhoneGlobals* aPhoneGlobals)
|
|
38 |
: CATDataCallConnectCommands(aIo,aTelObject,aInit,aPhoneGlobals)
|
|
39 |
{}
|
|
40 |
|
|
41 |
CATConnectData::~CATConnectData()
|
|
42 |
{}
|
|
43 |
|
|
44 |
void CATConnectData::Start(TTsyReqHandle aTsyReqHandle, TAny* aParams)
|
|
45 |
{
|
|
46 |
LOGTEXT(_L8("Starting Connect Command"));
|
|
47 |
iState=EATInitialising;
|
|
48 |
CATDataCallConnectCommands::Start(aTsyReqHandle,aParams);
|
|
49 |
}
|
|
50 |
|
|
51 |
void CATConnectData::Stop(TTsyReqHandle aTsyReqHandle)
|
|
52 |
//
|
|
53 |
// Send a carriage return to cancel Connect
|
|
54 |
//
|
|
55 |
{
|
|
56 |
__ASSERT_ALWAYS(aTsyReqHandle == iReqHandle,Panic(EIllegalTsyReqHandle));
|
|
57 |
__ASSERT_ALWAYS(iState!=EATNotInProgress,Panic(EATCommand_NotInProgress));
|
|
58 |
LOGTEXT(_L8("Cancelling Connect Command"));
|
|
59 |
RemoveConnectExpectStrings();
|
|
60 |
iIo->WriteAndTimerCancel(this);
|
|
61 |
if (iState!=EATInitialising)
|
|
62 |
{
|
|
63 |
Write(KCarriageReturn(),1);
|
|
64 |
iState = EATCancellingWaitForWriteComplete;
|
|
65 |
iPreConnectState=CATCallConnectCommands::ENotInProgress;
|
|
66 |
}
|
|
67 |
else
|
|
68 |
{
|
|
69 |
AddStdExpectStrings();
|
|
70 |
iPreConnectState=CATCallConnectCommands::ECancelling;
|
|
71 |
iState = EATNotInProgress;
|
|
72 |
}
|
|
73 |
}
|
|
74 |
|
|
75 |
TInt CATConnectData::AddConnectExpectStrings()
|
|
76 |
{
|
|
77 |
TInt ret=AddCommonExpectStrings();
|
|
78 |
if(ret!=KErrNone)
|
|
79 |
return ret;
|
|
80 |
|
|
81 |
if (!iNoDialToneExpectString)
|
|
82 |
{
|
|
83 |
ret=iPhoneGlobals->iConfiguration->ConfigModemString(TPtrC(KCDTypeNameNoDialTone),iNoDialToneString);
|
|
84 |
if(ret!=KErrNone)
|
|
85 |
return ret;
|
|
86 |
iNoDialToneExpectString=iIo->AddExpectString(this,iNoDialToneString);
|
|
87 |
}
|
|
88 |
|
|
89 |
return KErrNone;
|
|
90 |
}
|
|
91 |
|
|
92 |
void CATConnectData::RemoveConnectExpectStrings()
|
|
93 |
{
|
|
94 |
RemoveCommonExpectStrings();
|
|
95 |
iIo->RemoveExpectString(iNoDialToneExpectString);
|
|
96 |
iNoDialToneExpectString=NULL;
|
|
97 |
}
|
|
98 |
|
|
99 |
TInt CATConnectData::ValidateConnectExpectString()
|
|
100 |
{
|
|
101 |
const CCommChatString* foundChatString = iIo->FoundChatString();
|
|
102 |
|
|
103 |
if (foundChatString == iConnectExpectString)
|
|
104 |
return KErrNone;
|
|
105 |
|
|
106 |
if (foundChatString == iNoCarrierExpectString)
|
|
107 |
return KErrEtelNoCarrier;
|
|
108 |
|
|
109 |
if (foundChatString == iNoDialToneExpectString)
|
|
110 |
{
|
|
111 |
LOGTEXT(_L8("Modem returned NO DIALTONE in response to dial command"));
|
|
112 |
return KErrEtelNoDialTone;
|
|
113 |
}
|
|
114 |
|
|
115 |
LOGTEXT(_L8("Modem returned unknown response to connect command"));
|
|
116 |
return KErrGeneral;
|
|
117 |
}
|
|
118 |
|
|
119 |
void CATConnectData::CompleteWithIOError(TEventSource aSource,TInt aStatus)
|
|
120 |
{
|
|
121 |
if (iState!=EATNotInProgress)
|
|
122 |
{
|
|
123 |
iState = EATNotInProgress;
|
|
124 |
CATCallConnectCommands::CompleteWithIOError(aSource,aStatus);
|
|
125 |
}
|
|
126 |
}
|
|
127 |
|
|
128 |
void CATConnectData::EventSignal(TEventSource aSource)
|
|
129 |
{
|
|
130 |
if ((aSource==ETimeOutCompletion)&&(iState!=EATSpeedReadComplete)
|
|
131 |
&&(iState!=EATCancellingReadCompleted)&&(iState!=EATNotInProgress)
|
|
132 |
&&(iPreConnectState!=EATWaitForATCheckOK))
|
|
133 |
{
|
|
134 |
LOGTEXT(_L8("Timeout Error during Connect"));
|
|
135 |
iState = EATNotInProgress;
|
|
136 |
Complete(KErrTimedOut,aSource);
|
|
137 |
return;
|
|
138 |
}
|
|
139 |
|
|
140 |
if (iPreConnectState!=CATCallConnectCommands::EATInitCompleted
|
|
141 |
&& iPreConnectState!=CATCallConnectCommands::ENotInProgress)
|
|
142 |
{
|
|
143 |
CATCallConnectCommands::PreConnectEventSignal(aSource);
|
|
144 |
if (iPreConnectState==CATCallConnectCommands::ENotInProgress) // cancelled
|
|
145 |
iState=EATNotInProgress;
|
|
146 |
if (iPreConnectState!=CATCallConnectCommands::EATInitCompleted)
|
|
147 |
return;
|
|
148 |
else
|
|
149 |
iState=EATSendConnectCommand;
|
|
150 |
}
|
|
151 |
|
|
152 |
switch(iState)
|
|
153 |
{
|
|
154 |
case EATSendConnectCommand:
|
|
155 |
{
|
|
156 |
ChangeLineStatus(RCall::EStatusConnecting);
|
|
157 |
// EStatusConnecting always results in KErrNone return
|
|
158 |
(void)ChangeCallStatus(RMobileCall::EStatusConnecting);
|
|
159 |
iPhoneGlobals->iNotificationStore->CheckNotification(REINTERPRET_CAST(CCallBase*,iTelObject),EBegunConnecting);
|
|
160 |
Write(KDialCommand,3);
|
|
161 |
iState=EATConnectWaitForWriteComplete;
|
|
162 |
}
|
|
163 |
break;
|
|
164 |
|
|
165 |
case EATConnectWaitForWriteComplete:
|
|
166 |
{
|
|
167 |
__ASSERT_ALWAYS(aSource==EWriteCompletion,Panic(EATCommand_IllegalCompletionWriteExpected));
|
|
168 |
TInt ret=AddConnectExpectStrings();
|
|
169 |
if (ret)
|
|
170 |
{
|
|
171 |
Complete(ret,aSource);
|
|
172 |
break;
|
|
173 |
}
|
|
174 |
iIo->SetTimeOut(this,(iPhoneGlobals->iPhoneStatus.iWaitForCarrierTime*1000)+KExtraWaitTime);
|
|
175 |
iState=EATConnectReadCompleted;
|
|
176 |
break;
|
|
177 |
}
|
|
178 |
|
|
179 |
case EATConnectReadCompleted:
|
|
180 |
__ASSERT_ALWAYS(aSource==EReadCompletion,Panic(EATCommand_IllegalCompletionReadExpected));
|
|
181 |
{
|
|
182 |
TInt ret=ValidateConnectExpectString();
|
|
183 |
RemoveConnectExpectStrings();
|
|
184 |
if (ret!=KErrNone)
|
|
185 |
{
|
|
186 |
iState = EATNotInProgress;
|
|
187 |
Complete(ret,aSource);
|
|
188 |
}
|
|
189 |
iIo->SetTimeOut(this,KTimeForExtraRxData);
|
|
190 |
iState=EATSpeedReadComplete;
|
|
191 |
}
|
|
192 |
break;
|
|
193 |
|
|
194 |
case EATSpeedReadComplete:
|
|
195 |
{
|
|
196 |
__ASSERT_ALWAYS(aSource==ETimeOutCompletion,Panic(EATCommand_IllegalCompletionWaitExpected));
|
|
197 |
iIo->WriteAndTimerCancel(this);
|
|
198 |
TInt ret=ParseForBearerCapsResponse();
|
|
199 |
iState = EATNotInProgress;
|
|
200 |
if (ret!=KErrNone)
|
|
201 |
{
|
|
202 |
Complete(ret,aSource);
|
|
203 |
break;
|
|
204 |
}
|
|
205 |
ret=ParseForBearerSpeedResponse();
|
|
206 |
Complete(ret,aSource);
|
|
207 |
}
|
|
208 |
break;
|
|
209 |
|
|
210 |
case EATCancellingWaitForWriteComplete:
|
|
211 |
{
|
|
212 |
__ASSERT_ALWAYS(aSource==EWriteCompletion,Panic(EATCommand_IllegalCompletionWriteExpected));
|
|
213 |
TInt ret=AddConnectExpectStrings();
|
|
214 |
if (ret)
|
|
215 |
{
|
|
216 |
Complete(ret,aSource);
|
|
217 |
break;
|
|
218 |
}
|
|
219 |
iIo->SetTimeOut(this);
|
|
220 |
iState=EATCancellingReadCompleted;
|
|
221 |
}
|
|
222 |
break;
|
|
223 |
|
|
224 |
case EATCancellingReadCompleted:
|
|
225 |
{
|
|
226 |
iState = EATNotInProgress;
|
|
227 |
if (aSource==EReadCompletion)
|
|
228 |
{
|
|
229 |
TInt ret=ValidateConnectExpectString();
|
|
230 |
RemoveConnectExpectStrings();
|
|
231 |
if (ret==KErrNone)
|
|
232 |
{
|
|
233 |
Complete(KErrNone,aSource); // Has connected despite sending CR
|
|
234 |
return;
|
|
235 |
}
|
|
236 |
}
|
|
237 |
RemoveConnectExpectStrings();
|
|
238 |
Complete(KErrCancel,aSource);
|
|
239 |
}
|
|
240 |
break;
|
|
241 |
|
|
242 |
default:
|
|
243 |
;
|
|
244 |
}
|
|
245 |
}
|
|
246 |
|
|
247 |
|