|
1 // Copyright (c) 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 // CActivatContextAndGetAddr |
|
15 // |
|
16 |
|
17 #include <ctsy/ltsy/ltsylogger.h> |
|
18 |
|
19 #include "activatecontextandgetaddr.h" |
|
20 #include "mslogger.h" |
|
21 #include "athelpercommand.h" |
|
22 #include "atgprscontextactivate.h" |
|
23 #include "atgprsgetcontextaddr.h" |
|
24 #include "atgprscontextconnect.h" |
|
25 #include "commengine.h" |
|
26 |
|
27 _LIT8(KATDeleteContext2, "AT+CGDCONT=2\r"); |
|
28 _LIT8(KATDeleteContext3, "AT+CGDCONT=3\r"); |
|
29 _LIT8(KATDeleteContext4, "AT+CGDCONT=4\r"); |
|
30 |
|
31 // CActivatContextAndGetAddr |
|
32 // --------------------------------------------------------------------------- |
|
33 // CActivatContextAndGetAddr::NewL() |
|
34 // other items were commented in a header |
|
35 // --------------------------------------------------------------------------- |
|
36 CActivatContextAndGetAddr* CActivatContextAndGetAddr::NewL(CGlobalPhonemanager& aGloblePhone, |
|
37 CCtsyDispatcherCallback& aCtsyDispatcherCallback) |
|
38 { |
|
39 CActivatContextAndGetAddr* self = new(ELeave) CActivatContextAndGetAddr(aGloblePhone, |
|
40 aCtsyDispatcherCallback); |
|
41 CleanupStack::PushL(self ); |
|
42 self->ConstructL(); |
|
43 CleanupStack::Pop(self); |
|
44 return self ; |
|
45 } |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // CActivatContextAndGetAddr::CActivatContextAndGetAddr() |
|
49 // other items were commented in a header |
|
50 // --------------------------------------------------------------------------- |
|
51 CActivatContextAndGetAddr::CActivatContextAndGetAddr(CGlobalPhonemanager& aGloblePhone, |
|
52 CCtsyDispatcherCallback& aCtsyDispatcherCallback) |
|
53 :CATCommandControlBase(aGloblePhone,aCtsyDispatcherCallback) |
|
54 { |
|
55 } |
|
56 |
|
57 // --------------------------------------------------------------------------- |
|
58 // CActivatContextAndGetAddr::CActivatContextAndGetAddr() |
|
59 // other items were commented in a header |
|
60 // --------------------------------------------------------------------------- |
|
61 void CActivatContextAndGetAddr::ConstructL() |
|
62 { |
|
63 iATCommandName = EATNone; |
|
64 iATHelperCommand = CATHelperCommand::NewL(iPhoneGlobals,iCtsyDispatcherCallback); |
|
65 |
|
66 iATGprsContextActivate = CATGprsContextActivate::NewL(iPhoneGlobals, |
|
67 iCtsyDispatcherCallback); |
|
68 iATGPRSGetContextAddr = CATGPRSGetContextAddr::NewL(iPhoneGlobals, |
|
69 iCtsyDispatcherCallback); |
|
70 iATGprsContextConnect = CATGprsContextConnect::NewL(iPhoneGlobals, |
|
71 iCtsyDispatcherCallback); |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------------------------- |
|
75 // CActivatContextAndGetAddr::~CActivatContextAndGetAddr() |
|
76 // other items were commented in a header |
|
77 // --------------------------------------------------------------------------- |
|
78 CActivatContextAndGetAddr::~CActivatContextAndGetAddr() |
|
79 { |
|
80 delete iATHelperCommand; |
|
81 iATHelperCommand = NULL; |
|
82 |
|
83 delete iATGprsContextActivate; |
|
84 iATGprsContextActivate = NULL; |
|
85 |
|
86 delete iATGPRSGetContextAddr; |
|
87 iATGPRSGetContextAddr = NULL; |
|
88 |
|
89 delete iATGprsContextConnect; |
|
90 iATGprsContextConnect = NULL; |
|
91 } |
|
92 |
|
93 // --------------------------------------------------------------------------- |
|
94 // CActivatContextAndGetAddr::AtCommandExecuteComplete() |
|
95 // other items were commented in a header |
|
96 // --------------------------------------------------------------------------- |
|
97 void CActivatContextAndGetAddr::AtCommandExecuteComplete(TAtEventSource aEventSource, |
|
98 TInt aStatus) |
|
99 { |
|
100 if((aEventSource == EWriteCompletion)&&(KErrNone == aStatus)) |
|
101 { |
|
102 return; |
|
103 } |
|
104 |
|
105 TInt ret = KErrNone; |
|
106 switch(iATType) |
|
107 { |
|
108 case ELtsyAT_Packet_DeleteContext2: |
|
109 ret = iATHelperCommand->GetErrorValue(); |
|
110 if ((KErrNone == ret) && (KErrNone == aStatus)) |
|
111 { |
|
112 ExecuteATHelpCommand(KATDeleteContext3,ELtsyAT_Packet_DeleteContext3); |
|
113 } |
|
114 else |
|
115 { |
|
116 EndATCommand(iATHelperCommand); |
|
117 iPhoneGlobals.iEventSignalActive = EFalse; |
|
118 LOGTEXT3(_L8("[Ltsy] DeleteContext2 failed (%d or %d) in CActivatContextAndGetAddr"), ret, aStatus); |
|
119 DispatcherCallback(KErrGeneral); |
|
120 } |
|
121 break; |
|
122 case ELtsyAT_Packet_DeleteContext3: |
|
123 ret = iATHelperCommand->GetErrorValue(); |
|
124 if ((KErrNone == ret) && (KErrNone == aStatus)) |
|
125 { |
|
126 ExecuteATHelpCommand(KATDeleteContext4,ELtsyAT_Packet_DeleteContext4); |
|
127 } |
|
128 else |
|
129 { |
|
130 EndATCommand(iATHelperCommand); |
|
131 iPhoneGlobals.iEventSignalActive = EFalse; |
|
132 LOGTEXT3(_L8("[Ltsy] DeleteContext3 failed (%d or %d) in CActivatContextAndGetAddr"), ret, aStatus); |
|
133 DispatcherCallback(KErrGeneral); |
|
134 } |
|
135 break; |
|
136 case ELtsyAT_Packet_DeleteContext4: |
|
137 ret = iATHelperCommand->GetErrorValue(); |
|
138 EndATCommand(iATHelperCommand); |
|
139 if ((KErrNone == ret) && (KErrNone == aStatus)) |
|
140 { |
|
141 iATGprsContextActivate->SetContext(iContextId); |
|
142 StartATCommand(iATGprsContextActivate); |
|
143 } |
|
144 else |
|
145 { |
|
146 iPhoneGlobals.iEventSignalActive = EFalse; |
|
147 LOGTEXT3(_L8("[Ltsy] DeleteContext4 failed (%d or %d) in CActivatContextAndGetAddr"), ret, aStatus); |
|
148 DispatcherCallback(KErrGeneral); |
|
149 } |
|
150 break; |
|
151 case ELtsyAT_Packet_ActivateContext: |
|
152 EndATCommand(iATGprsContextActivate); |
|
153 if(aStatus == KErrNone) |
|
154 { |
|
155 ret = iATGprsContextActivate->GetErrorValue(); |
|
156 if(KErrNone == ret) |
|
157 { |
|
158 iATGPRSGetContextAddr->SetContext(iContextId); |
|
159 StartATCommand(iATGPRSGetContextAddr); |
|
160 } |
|
161 else |
|
162 { |
|
163 iPhoneGlobals.iEventSignalActive = EFalse; |
|
164 DispatcherCallback(ret); |
|
165 } |
|
166 } |
|
167 else |
|
168 { |
|
169 iPhoneGlobals.iEventSignalActive = EFalse; |
|
170 DispatcherCallback(aStatus); |
|
171 } |
|
172 break; |
|
173 case ELtsyAT_Packet_GetContextAddr: |
|
174 EndATCommand(iATGPRSGetContextAddr); |
|
175 if(aStatus == KErrNone) |
|
176 { |
|
177 ret = iATGPRSGetContextAddr->GetErrorValue(); |
|
178 if(KErrNone == ret) |
|
179 { |
|
180 iATGprsContextConnect->SetContext(iContextId); |
|
181 StartATCommand(iATGprsContextConnect); |
|
182 } |
|
183 else |
|
184 { |
|
185 iPhoneGlobals.iEventSignalActive = EFalse; |
|
186 DispatcherCallback(ret); |
|
187 } |
|
188 } |
|
189 else |
|
190 { |
|
191 iPhoneGlobals.iEventSignalActive = EFalse; |
|
192 DispatcherCallback(aStatus); |
|
193 } |
|
194 break; |
|
195 case ELtsyAT_Packet_ConnectContext: |
|
196 EndATCommand(iATGprsContextConnect); |
|
197 if(aStatus == KErrNone) |
|
198 { |
|
199 ret = iATGprsContextConnect->GetErrorValue(); |
|
200 if(KErrNone == aStatus) |
|
201 { |
|
202 iConnectionSpeed = iATGprsContextConnect->GetConnectionSpeed(); |
|
203 } |
|
204 DispatcherCallback(ret); |
|
205 } |
|
206 else |
|
207 { |
|
208 DispatcherCallback(aStatus); |
|
209 } |
|
210 iPhoneGlobals.iEventSignalActive = EFalse; |
|
211 break; |
|
212 default: |
|
213 break; |
|
214 } |
|
215 } |
|
216 |
|
217 // --------------------------------------------------------------------------- |
|
218 // CActivatContextAndGetAddr::StartRequest() |
|
219 // other items were commented in a header |
|
220 // --------------------------------------------------------------------------- |
|
221 void CActivatContextAndGetAddr::StartRequest() |
|
222 { |
|
223 iATHelperCommand->SetAtCommandObserver(this); |
|
224 ExecuteATHelpCommand(KATDeleteContext2,ELtsyAT_Packet_DeleteContext2); |
|
225 } |
|
226 |
|
227 // --------------------------------------------------------------------------- |
|
228 // CActivatContextAndGetAddr::SetContext() |
|
229 // other items were commented in a header |
|
230 // --------------------------------------------------------------------------- |
|
231 void CActivatContextAndGetAddr::SetContext(const TInt aContextId) |
|
232 { |
|
233 iContextId = aContextId; |
|
234 } |
|
235 |
|
236 // --------------------------------------------------------------------------- |
|
237 // CActivatContextAndGetAddr::ExecuteNextATHelpCommand |
|
238 // other items were commented in a header |
|
239 // --------------------------------------------------------------------------- |
|
240 void CActivatContextAndGetAddr::ExecuteATHelpCommand(const TDesC8& aATString,TLtsyATCommandType aATType) |
|
241 { |
|
242 iATHelperCommand->Complete(); |
|
243 iATHelperCommand->SetAtCommandString(aATString); |
|
244 iATType = aATType; |
|
245 iATHelperCommand->StartRequest(); |
|
246 } |
|
247 |
|
248 // --------------------------------------------------------------------------- |
|
249 // CActivatContextAndGetAddr::StartATCommand |
|
250 // other items were commented in a header |
|
251 // --------------------------------------------------------------------------- |
|
252 void CActivatContextAndGetAddr::StartATCommand(CAtCommandBase* aAtCommand) |
|
253 { |
|
254 aAtCommand->SetAtCommandObserver(this); |
|
255 iATType = aAtCommand->AtType(); |
|
256 aAtCommand->StartRequest(); |
|
257 } |
|
258 |
|
259 // --------------------------------------------------------------------------- |
|
260 // CActivatContextAndGetAddr::EndATCommand |
|
261 // other items were commented in a header |
|
262 // --------------------------------------------------------------------------- |
|
263 void CActivatContextAndGetAddr::EndATCommand(CAtCommandBase* aAtCommand) |
|
264 { |
|
265 aAtCommand->RemoveAtCommandObserver(); |
|
266 aAtCommand->Complete(); |
|
267 } |
|
268 |
|
269 // --------------------------------------------------------------------------- |
|
270 // CActivatContextAndGetAddr::DispatcherCallback() |
|
271 // other items were commented in a header |
|
272 // --------------------------------------------------------------------------- |
|
273 void CActivatContextAndGetAddr::DispatcherCallback(TInt aError) |
|
274 { |
|
275 TInt count = iPhoneGlobals.iContextList.Count(); |
|
276 TInt i = 0; |
|
277 |
|
278 //Get the context from context list |
|
279 for(i = 0; i < count;i++) |
|
280 { |
|
281 if(iPhoneGlobals.iContextList[i]->iContextID == iContextId) |
|
282 { |
|
283 break; |
|
284 } |
|
285 } |
|
286 iCtsyDispatcherCallback.CallbackPacketServicesActivatePdpContextComp(aError, |
|
287 iPhoneGlobals.iContextList[i]->iInfo.iName, |
|
288 iPhoneGlobals.iContextList[i]->iDefContextConfigGPRS.iAccessPointName, |
|
289 iPhoneGlobals.iContextList[i]->iDefContextConfigGPRS.iPdpType); |
|
290 if(aError == KErrNone) |
|
291 { |
|
292 iPhoneGlobals.iContextList[i]->iInfo.iStatus = RPacketContext::EStatusActive; |
|
293 TContextMisc contextMisc; |
|
294 contextMisc.iStatus = RPacketContext::EStatusActive; |
|
295 iPhoneGlobals.iPhoneStatus.iMode = RPhone::EModeOnlineData; |
|
296 iCtsyDispatcherCallback.CallbackPacketServicesNotifyPdpContextStatusChangeInd(aError, |
|
297 iPhoneGlobals.iContextList[i]->iInfo.iName, |
|
298 contextMisc); |
|
299 iCtsyDispatcherCallback.CallbackPacketServicesNotifyPdpContextConfigChangedInd(aError, |
|
300 iPhoneGlobals.iContextList[i]->iInfo.iName, |
|
301 iPhoneGlobals.iContextList[i]->iDefContextConfigGPRS.iAccessPointName, |
|
302 iPhoneGlobals.iContextList[i]->iDefContextConfigGPRS.iPdpAddress, |
|
303 0, |
|
304 iPhoneGlobals.iContextList[i]->iDefContextConfigGPRS.iProtocolConfigOption.iMiscBuffer); |
|
305 iCtsyDispatcherCallback.CallbackPacketServicesNotifyPdpContextConnectionSpeedChangeInd(aError, |
|
306 iPhoneGlobals.iContextList[i]->iInfo.iName, |
|
307 iConnectionSpeed); |
|
308 iPhoneGlobals.iCommEngine->CommCancel(); |
|
309 } |
|
310 } |
|
311 |
|
312 // |
|
313 // End of file |