|
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 // CATGetModemStatus |
|
15 // Description: |
|
16 // CGetCurrentNetworkInfo |
|
17 |
|
18 #include <ctsy/ltsy/cctsydispatchercallback.h> |
|
19 #include <ctsy/ltsy/mltsydispatchphoneinterface.h> |
|
20 #include "getcurrentnetworkinfo.h" |
|
21 #include "mslogger.h" |
|
22 #include "atgetnetworkinfo.h" |
|
23 |
|
24 // define the AT command format |
|
25 _LIT8(KATSetFormatForLongName, "AT+COPS=3,0\r"); |
|
26 _LIT8(KATSetFormatForShortName, "AT+COPS=3,1\r"); |
|
27 _LIT8(KATSetNumbericFormat, "AT+COPS=3,2\r"); |
|
28 |
|
29 // Class CGetCurrentNetworkInfo |
|
30 // --------------------------------------------------------------------------- |
|
31 // CGetCurrentNetworkInfo::NewL |
|
32 // other items were commented in a header |
|
33 // --------------------------------------------------------------------------- |
|
34 CGetCurrentNetworkInfo* CGetCurrentNetworkInfo::NewL(CGlobalPhonemanager& aGloblePhone, |
|
35 CCtsyDispatcherCallback& aCtsyDispatcherCallback) |
|
36 { |
|
37 CGetCurrentNetworkInfo* self = new(ELeave) CGetCurrentNetworkInfo(aGloblePhone, |
|
38 aCtsyDispatcherCallback); |
|
39 CleanupStack::PushL(self ); |
|
40 self->ConstructL(); |
|
41 CleanupStack::Pop(); |
|
42 return self ; |
|
43 } |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // CGetCurrentNetworkInfo::CGetCurrentNetworkInfo |
|
47 // other items were commented in a header |
|
48 // --------------------------------------------------------------------------- |
|
49 CGetCurrentNetworkInfo::CGetCurrentNetworkInfo(CGlobalPhonemanager& aGloblePhone, |
|
50 CCtsyDispatcherCallback& aCtsyDispatcherCallback) |
|
51 :CATCommandControlBase(aGloblePhone,aCtsyDispatcherCallback) |
|
52 { |
|
53 } |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // CGetCurrentNetworkInfo::ConstructL |
|
57 // other items were commented in a header |
|
58 // --------------------------------------------------------------------------- |
|
59 void CGetCurrentNetworkInfo::ConstructL() |
|
60 { |
|
61 LOGTEXT(_L8("[Ltsy Phone Control] Starting CATAnswer::ConstructL")); |
|
62 iState = EATUnknown; |
|
63 iATNetworkInfo = CATNetworkInfo::NewL(iPhoneGlobals,iCtsyDispatcherCallback); |
|
64 iATHelperCommand = CATHelperCommand::NewL(iPhoneGlobals,iCtsyDispatcherCallback); |
|
65 } |
|
66 |
|
67 // --------------------------------------------------------------------------- |
|
68 // CGetCurrentNetworkInfo::~CGetCurrentNetworkInfo |
|
69 // other items were commented in a header |
|
70 // --------------------------------------------------------------------------- |
|
71 CGetCurrentNetworkInfo::~CGetCurrentNetworkInfo() |
|
72 { |
|
73 LOGTEXT(_L8("[Ltsy Phone Control] Starting CATAnswer::~CGetCurrentNetworkInfo()")); |
|
74 delete iATHelperCommand; |
|
75 iATHelperCommand = NULL; |
|
76 delete iATNetworkInfo; |
|
77 iATNetworkInfo = NULL; |
|
78 } |
|
79 |
|
80 // --------------------------------------------------------------------------- |
|
81 // CGetCurrentNetworkInfo::AtCommandExecuteComplete |
|
82 // other items were commented in a header |
|
83 // --------------------------------------------------------------------------- |
|
84 void CGetCurrentNetworkInfo::AtCommandExecuteComplete(TAtEventSource aEventSource, TInt aStatus) |
|
85 { |
|
86 if((aEventSource == EWriteCompletion)&&(KErrNone == aStatus)) |
|
87 { |
|
88 return; |
|
89 } |
|
90 |
|
91 switch(iState) |
|
92 { |
|
93 case EATSetLongFormat: |
|
94 LOGTEXT(_L8("[Ltsy Phone Control] complete EATSetLongFormat")); |
|
95 CompeteATCommand(iATHelperCommand); |
|
96 if(aStatus != KErrNone) |
|
97 { |
|
98 HandleGetCurNetworkError(aStatus); |
|
99 } |
|
100 else |
|
101 { |
|
102 aStatus = iATHelperCommand->GetErrorValue(); |
|
103 if(aStatus != KErrNone) |
|
104 { |
|
105 HandleGetCurNetworkError(aStatus); |
|
106 } |
|
107 else |
|
108 { |
|
109 iState = EATGetLongName; |
|
110 GetNetworkLongName(); |
|
111 } |
|
112 } |
|
113 break; |
|
114 |
|
115 case EATGetLongName: |
|
116 LOGTEXT(_L8("[Ltsy Phone Control] complete EATGetLongName")); |
|
117 CompeteATCommand(iATNetworkInfo); |
|
118 if(aStatus != KErrNone) |
|
119 { |
|
120 HandleGetCurNetworkError(aStatus); |
|
121 } |
|
122 else |
|
123 { |
|
124 TInt err = iATNetworkInfo->GetErrorValue(); |
|
125 if(err != KErrNone) |
|
126 { |
|
127 HandleGetCurNetworkError(err); |
|
128 } |
|
129 else |
|
130 { |
|
131 iState = EATSetShortFormat; |
|
132 SetShortNameFormat(); |
|
133 } |
|
134 } |
|
135 break; |
|
136 |
|
137 case EATSetShortFormat: |
|
138 LOGTEXT(_L8("[Ltsy Phone Control] complete EATSetShortFormat")); |
|
139 CompeteATCommand(iATHelperCommand); |
|
140 if(aStatus != KErrNone) |
|
141 { |
|
142 HandleGetCurNetworkError(aStatus); |
|
143 } |
|
144 else |
|
145 { |
|
146 aStatus = iATHelperCommand->GetErrorValue(); |
|
147 if(aStatus != KErrNone) |
|
148 { |
|
149 HandleGetCurNetworkError(aStatus); |
|
150 } |
|
151 else |
|
152 { |
|
153 iState = EATGetShortName; |
|
154 GetNetworkShortName(); |
|
155 } |
|
156 } |
|
157 break; |
|
158 |
|
159 case EATGetShortName: |
|
160 LOGTEXT(_L8("[Ltsy Phone Control] complete EATGetShortName")); |
|
161 CompeteATCommand(iATNetworkInfo); |
|
162 if(aStatus != KErrNone) |
|
163 { |
|
164 HandleGetCurNetworkError(aStatus); |
|
165 } |
|
166 else |
|
167 { |
|
168 TInt err = iATNetworkInfo->GetErrorValue(); |
|
169 if(err != KErrNone) |
|
170 { |
|
171 HandleGetCurNetworkError(err); |
|
172 } |
|
173 else |
|
174 { |
|
175 iState = EATSetNumbericFormat; |
|
176 SetNumbericFormat(); |
|
177 } |
|
178 } |
|
179 break; |
|
180 case EATSetNumbericFormat: |
|
181 LOGTEXT(_L8("[Ltsy Phone Control] complete EATSetNumbericFormat")); |
|
182 CompeteATCommand(iATHelperCommand); |
|
183 if(aStatus != KErrNone) |
|
184 { |
|
185 HandleGetCurNetworkError(aStatus); |
|
186 } |
|
187 else |
|
188 { |
|
189 aStatus = iATHelperCommand->GetErrorValue(); |
|
190 if(aStatus != KErrNone) |
|
191 { |
|
192 HandleGetCurNetworkError(aStatus); |
|
193 } |
|
194 else |
|
195 { |
|
196 iState = EATGetCountryCodeAndNetwrokId; |
|
197 GetCountryCodeAndNetworkId(); |
|
198 } |
|
199 } |
|
200 break; |
|
201 case EATGetCountryCodeAndNetwrokId: |
|
202 LOGTEXT(_L8("[Ltsy Phone Control] complete EATGetCountryCodeAndNetwrokId")); |
|
203 CompeteATCommand(iATNetworkInfo); |
|
204 if(aStatus != KErrNone) |
|
205 { |
|
206 HandleGetCurNetworkError(aStatus); |
|
207 } |
|
208 else |
|
209 { |
|
210 TInt err = iATNetworkInfo->GetErrorValue(); |
|
211 if(err != KErrNone) |
|
212 { |
|
213 HandleGetCurNetworkError(err); |
|
214 } |
|
215 else |
|
216 { |
|
217 iState = EATUnknown; |
|
218 HandleGetCurNetworkComplete(); |
|
219 } |
|
220 } |
|
221 break; |
|
222 |
|
223 default: |
|
224 break; |
|
225 } |
|
226 } |
|
227 |
|
228 // --------------------------------------------------------------------------- |
|
229 // CGetCurrentNetworkInfo::StartRequestL |
|
230 // other items were commented in a header |
|
231 // --------------------------------------------------------------------------- |
|
232 void CGetCurrentNetworkInfo::StartRequest() |
|
233 { |
|
234 LOGTEXT(_L8("[Ltsy Phone Control] Starting CATAnswer::StartRequest()")); |
|
235 iState = EATSetLongFormat; |
|
236 SetLongNameFormat(); |
|
237 } |
|
238 |
|
239 // --------------------------------------------------------------------------- |
|
240 // CGetCurrentNetworkInfo::StartATCommand |
|
241 // other items were commented in a header |
|
242 // --------------------------------------------------------------------------- |
|
243 void CGetCurrentNetworkInfo::StartATCommand(CAtCommandBase* aAtCommand) |
|
244 { |
|
245 aAtCommand->SetAtCommandObserver(this); |
|
246 aAtCommand->StartRequest(); |
|
247 } |
|
248 |
|
249 // --------------------------------------------------------------------------- |
|
250 // CGetCurrentNetworkInfo::EndATCommand |
|
251 // other items were commented in a header |
|
252 // --------------------------------------------------------------------------- |
|
253 void CGetCurrentNetworkInfo::CompeteATCommand(CAtCommandBase* aAtCommand) |
|
254 { |
|
255 aAtCommand->RemoveAtCommandObserver(); |
|
256 aAtCommand->Complete(); |
|
257 } |
|
258 |
|
259 // --------------------------------------------------------------------------- |
|
260 // CGetCurrentNetworkInfo::SetLongNameFormat |
|
261 // other items were commented in a header |
|
262 // --------------------------------------------------------------------------- |
|
263 void CGetCurrentNetworkInfo::SetLongNameFormat() |
|
264 { |
|
265 iATHelperCommand->SetAtCommandString(KATSetFormatForLongName); |
|
266 StartATCommand(iATHelperCommand); |
|
267 } |
|
268 |
|
269 // --------------------------------------------------------------------------- |
|
270 // CGetCurrentNetworkInfo::SetLongNameFormat |
|
271 // other items were commented in a header |
|
272 // --------------------------------------------------------------------------- |
|
273 void CGetCurrentNetworkInfo::GetNetworkLongName() |
|
274 { |
|
275 StartATCommand(iATNetworkInfo); |
|
276 } |
|
277 |
|
278 // --------------------------------------------------------------------------- |
|
279 // CGetCurrentNetworkInfo::SetLongNameFormat |
|
280 // other items were commented in a header |
|
281 // --------------------------------------------------------------------------- |
|
282 void CGetCurrentNetworkInfo::SetShortNameFormat() |
|
283 { |
|
284 iATHelperCommand->SetAtCommandString(KATSetFormatForShortName); |
|
285 StartATCommand(iATHelperCommand); |
|
286 } |
|
287 |
|
288 // --------------------------------------------------------------------------- |
|
289 // CGetCurrentNetworkInfo::GetNetworkShortName |
|
290 // other items were commented in a header |
|
291 // --------------------------------------------------------------------------- |
|
292 void CGetCurrentNetworkInfo::GetNetworkShortName() |
|
293 { |
|
294 StartATCommand(iATNetworkInfo); |
|
295 } |
|
296 |
|
297 // --------------------------------------------------------------------------- |
|
298 // CGetCurrentNetworkInfo::SetShortNumbericFormat |
|
299 // other items were commented in a header |
|
300 // --------------------------------------------------------------------------- |
|
301 void CGetCurrentNetworkInfo::SetNumbericFormat() |
|
302 { |
|
303 iATHelperCommand->SetAtCommandString(KATSetNumbericFormat); |
|
304 StartATCommand(iATHelperCommand); |
|
305 } |
|
306 |
|
307 // --------------------------------------------------------------------------- |
|
308 // CGetCurrentNetworkInfo::SetShortNumbericFormat |
|
309 // other items were commented in a header |
|
310 // --------------------------------------------------------------------------- |
|
311 void CGetCurrentNetworkInfo::GetCountryCodeAndNetworkId() |
|
312 { |
|
313 StartATCommand(iATNetworkInfo); |
|
314 } |
|
315 |
|
316 // --------------------------------------------------------------------------- |
|
317 // CGetCurrentNetworkInfo::HandleGetCurNetworkError |
|
318 // other items were commented in a header |
|
319 // --------------------------------------------------------------------------- |
|
320 void CGetCurrentNetworkInfo::HandleGetCurNetworkError(TInt aError) |
|
321 { |
|
322 iCtsyDispatcherCallback.CallbackPhoneGetCurrentNetworkInfoComp(aError, |
|
323 iNetworkInfo, |
|
324 iPhoneGlobals.iPhoneStatus.iLocationArea); |
|
325 } |
|
326 |
|
327 // --------------------------------------------------------------------------- |
|
328 // CGetCurrentNetworkInfo::HandleGetCurNetworkComplete |
|
329 // other items were commented in a header |
|
330 // --------------------------------------------------------------------------- |
|
331 void CGetCurrentNetworkInfo::HandleGetCurNetworkComplete() |
|
332 { |
|
333 LOGTEXT(_L8("[Ltsy Phone Control] CGetCurrentNetworkInfo::HandleGetCurNetworkComplete()")); |
|
334 iNetworkInfo = iATNetworkInfo->GetNetWorkInfo(); |
|
335 iPhoneGlobals.iPhoneStatus.iCurrentNetwork = iNetworkInfo; |
|
336 iPhoneGlobals.iEventSignalActive = EFalse; |
|
337 iCtsyDispatcherCallback.CallbackPhoneGetCurrentNetworkInfoComp(KErrNone, |
|
338 iNetworkInfo, |
|
339 iPhoneGlobals.iPhoneStatus.iLocationArea); |
|
340 |
|
341 if(iIpcCompleteObserver) |
|
342 { |
|
343 iIpcCompleteObserver->NotifyIpcRequestComplete(MLtsyDispatchPhoneGetCurrentNetworkInfo::KLtsyDispatchPhoneGetCurrentNetworkInfoApiId); |
|
344 } |
|
345 } |
|
346 |
|
347 // End of file |