|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Contains the implementation of dialog monitor |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 //#include <basched.h> |
|
22 #include "OnlineSupportLogger.h" |
|
23 #include "ccmdialogmonitor.h" |
|
24 #include "mcmdialogstatusnotifier.h" |
|
25 |
|
26 // EXTERNAL DATA STRUCTURES |
|
27 // None |
|
28 |
|
29 // EXTERNAL FUNCTION PROTOTYPES |
|
30 // None |
|
31 |
|
32 // CONSTANTS |
|
33 // PhoneModule name |
|
34 |
|
35 |
|
36 // MACROS |
|
37 // None |
|
38 |
|
39 // LOCAL CONSTANTS AND MACROS |
|
40 // None |
|
41 |
|
42 // MODULE DATA STRUCTURES |
|
43 // None |
|
44 |
|
45 // LOCAL FUNCTION PROTOTYPES |
|
46 // None |
|
47 |
|
48 // FORWARD DECLARATIONS |
|
49 // None |
|
50 |
|
51 // ============================= LOCAL FUNCTIONS =============================== |
|
52 // None |
|
53 |
|
54 // ============================ MEMBER FUNCTIONS =============================== |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // CCMDialogMonitor::CCMDialogMonitor |
|
58 // C++ default constructor can NOT contain any code, that |
|
59 // might leave. |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 |
|
63 CCMDialogMonitor::CCMDialogMonitor( MCMDialogStatusNotifier& aNotifier ) : |
|
64 CActive( CActive::EPriorityStandard ), |
|
65 iNotifier( aNotifier ) |
|
66 { |
|
67 } |
|
68 |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CCMDialogMonitor::ConstructL |
|
72 // Symbian 2nd phase constructor can leave. |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 void CCMDialogMonitor::ConstructL() |
|
76 { |
|
77 CActiveScheduler::Add(this); |
|
78 } |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // CCMDialogMonitor::NewL |
|
82 // Two-phased constructor. |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 CCMDialogMonitor* CCMDialogMonitor::NewL( MCMDialogStatusNotifier& aNotifier ) |
|
86 { |
|
87 CCMDialogMonitor* self = new( ELeave ) CCMDialogMonitor( aNotifier ); |
|
88 CleanupStack::PushL( self ); |
|
89 self->ConstructL(); |
|
90 CleanupStack::Pop(); |
|
91 return self; |
|
92 } |
|
93 |
|
94 // Destructor |
|
95 CCMDialogMonitor::~CCMDialogMonitor() |
|
96 { |
|
97 if( IsActive() ) |
|
98 { |
|
99 Cancel(); |
|
100 } |
|
101 } |
|
102 |
|
103 void CCMDialogMonitor::SetDialogMode(TDialogMode aMode) |
|
104 { |
|
105 iDialogMode = aMode; |
|
106 } |
|
107 |
|
108 void CCMDialogMonitor::Start() |
|
109 { |
|
110 if( IsActive() ) |
|
111 { |
|
112 Cancel(); |
|
113 } |
|
114 SetActive(); |
|
115 } |
|
116 |
|
117 void CCMDialogMonitor::DoCancel() |
|
118 { |
|
119 } |
|
120 |
|
121 //TInt CCMDialogMonitor::RunError( TInt aError ) |
|
122 // { |
|
123 // return aError; |
|
124 // } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // CCMDialogMonitor::StartMonitoring() |
|
128 // Starts monitoring of the network registeration status |
|
129 // (other items were commented in a header). |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 /* |
|
133 void CCMDialogMonitor::StartMonitoring() |
|
134 { |
|
135 if( IsActive() ) |
|
136 { |
|
137 Cancel(); |
|
138 } |
|
139 iStartTime.HomeTime(); |
|
140 #ifdef __WINS__ // do not try to connect on the emulator |
|
141 iRegisterationStatus = RMobilePhone::ERegisteredOnHomeNetwork; |
|
142 TRequestStatus* status = &iStatus; |
|
143 User::RequestComplete( status, KErrNone ); |
|
144 #else |
|
145 iPhone.GetNetworkRegistrationStatus( iStatus, iRegisterationStatus ); |
|
146 #endif |
|
147 iMonitoringStatus = ERequestingNetworkStatus; |
|
148 SetActive(); |
|
149 } |
|
150 */ |
|
151 // ----------------------------------------------------------------------------- |
|
152 // CCMDialogMonitor::StopMonitoring() |
|
153 // Stops the registeration monitor |
|
154 // (other items were commented in a header). |
|
155 // ----------------------------------------------------------------------------- |
|
156 // |
|
157 /* |
|
158 void CCMDialogMonitor::StopMonitoring() |
|
159 { |
|
160 LOGSTRING( "Enter to CCMDialogMonitor::StopMonitoring " ); |
|
161 if( IsActive() ) |
|
162 { |
|
163 Cancel(); |
|
164 } |
|
165 LOGSTRING( "Exit from CCMDialogMonitor::StopMonitoring " ); |
|
166 } |
|
167 */ |
|
168 // ----------------------------------------------------------------------------- |
|
169 // CCMDialogMonitor::DoCancel() |
|
170 // Cancels the monitoring |
|
171 // (other items were commented in a header). |
|
172 // ----------------------------------------------------------------------------- |
|
173 // |
|
174 /* |
|
175 void CCMDialogMonitor::DoCancel() |
|
176 { |
|
177 LOGSTRING("CCMDialogMonitor::DoCancel"); |
|
178 switch( iMonitoringStatus ) |
|
179 { |
|
180 case EInactive: |
|
181 User::Leave( KErrUnderflow ); |
|
182 break; |
|
183 case ERequestingNetworkStatus: |
|
184 iPhone.CancelAsyncRequest( EMobilePhoneGetNetworkRegistrationStatus ); |
|
185 iMonitoringStatus = EInactive; |
|
186 break; |
|
187 case EWaitingForChangesInNetworkStatus: |
|
188 iPhone.CancelAsyncRequest( EMobilePhoneNotifyNetworkRegistrationStatusChange ); |
|
189 iMonitoringStatus = EInactive; |
|
190 break; |
|
191 case ERequestingServiceProviderName: |
|
192 iPhone.CancelAsyncRequest( EMobilePhoneGetServiceProviderName ); |
|
193 iMonitoringStatus = EInactive; |
|
194 break; |
|
195 case ERequestingHomeNetworkInfo: |
|
196 iPhone.CancelAsyncRequest( EMobilePhoneGetHomeNetwork ); |
|
197 iMonitoringStatus = EInactive; |
|
198 break; |
|
199 case ERequestingCurrentNetworkInfo: |
|
200 iPhone.CancelAsyncRequest( EMobilePhoneGetCurrentNetworkNoLocation ); |
|
201 iMonitoringStatus = EInactive; |
|
202 break; |
|
203 case ERequestingOwnNumberInfo: |
|
204 iMonitoringStatus = EInactive; |
|
205 break; |
|
206 case ERequestingPhoneIdentity: |
|
207 iPhone.CancelAsyncRequest( EMobilePhoneGetPhoneId ); |
|
208 iMonitoringStatus = EInactive; |
|
209 break; |
|
210 case ERequestingIMSI: |
|
211 iPhone.CancelAsyncRequest( EMobilePhoneGetSubscriberId ); |
|
212 iMonitoringStatus = EInactive; |
|
213 break; |
|
214 default: |
|
215 User::Leave( KErrOverflow ); |
|
216 break; |
|
217 } |
|
218 |
|
219 TInt err( KErrNone ); |
|
220 TRAP( err, iNotifier.RegistrationReportErrorL( iMonitoringStatus, KErrCancel ) ); |
|
221 LOGSTRING("Monitoring Cancelled"); |
|
222 } |
|
223 */ |
|
224 /* |
|
225 TInt CCMDialogMonitor::RunError( TInt aError ) |
|
226 { |
|
227 LOGSTRING2( "CCMDialogMonitor::RunError %i", aError ); |
|
228 TInt err( KErrNone ); |
|
229 TRAP( err, iNotifier.RegistrationReportErrorL( iMonitoringStatus, aError ) ); |
|
230 if( err == KLeaveExit ) |
|
231 { |
|
232 User::Leave( KLeaveExit ); |
|
233 } |
|
234 if( aError == KLeaveExit ) |
|
235 { |
|
236 User::Leave( KLeaveExit ); |
|
237 } |
|
238 LOGSTRING( "CCMDialogMonitor::RunError - done" ); |
|
239 return KErrNone; |
|
240 } |
|
241 */ |
|
242 // ----------------------------------------------------------------------------- |
|
243 // CCMDialogMonitor::RunL() |
|
244 // Handles object’s request completion event |
|
245 // (other items were commented in a header). |
|
246 // ----------------------------------------------------------------------------- |
|
247 // |
|
248 void CCMDialogMonitor::RunL() |
|
249 { |
|
250 LOGSTRING("Enter to CCMDialogMonitor::RunL() "); |
|
251 LOGSTRING2( "CCMDialogMonitor status %i" , iStatus.Int() ); |
|
252 |
|
253 iNotifier.CommonDialogDismissedL( iDialogMode, iStatus.Int() ); |
|
254 /* |
|
255 switch( iMonitoringStatus ) |
|
256 { |
|
257 case EInactive: |
|
258 User::Leave( KErrUnderflow ); |
|
259 break; |
|
260 case ERequestingNetworkStatus: |
|
261 case EWaitingForChangesInNetworkStatus: |
|
262 { |
|
263 LOGSTRING( "ERequestingNetworkStatus | EWaitingForChangesInNetworkStatus" ); |
|
264 switch( iRegisterationStatus ) |
|
265 { |
|
266 // Not Ok cases |
|
267 case RMobilePhone::ERegistrationUnknown: |
|
268 case RMobilePhone::ENotRegisteredNoService: |
|
269 case RMobilePhone::ENotRegisteredEmergencyOnly: |
|
270 case RMobilePhone::ENotRegisteredSearching: |
|
271 case RMobilePhone::ERegisteredBusy: |
|
272 case RMobilePhone::ERegistrationDenied: |
|
273 currentTime.HomeTime(); |
|
274 currentTime.SecondsFrom( iStartTime, interval ); |
|
275 seconds = interval.Int(); |
|
276 if ( seconds > KMaxInterval ) |
|
277 { |
|
278 iMonitoringStatus = EInactive; |
|
279 // Report error |
|
280 iNotifier.RegistrationMonitoringDoneL( EStatusUnknown ); |
|
281 } |
|
282 else |
|
283 { |
|
284 iMonitoringStatus = EWaitingForChangesInNetworkStatus; |
|
285 iPhone.NotifyNetworkRegistrationStatusChange( iStatus, iRegisterationStatus ); |
|
286 LOGSTRING( "Network registration status change notification started " ); |
|
287 SetActive(); |
|
288 } |
|
289 break; |
|
290 // These are Ok |
|
291 case RMobilePhone::ERegisteredOnHomeNetwork: |
|
292 case RMobilePhone::ERegisteredRoaming: |
|
293 iMonitoringStatus = ERequestingServiceProviderName; |
|
294 iPhone.GetServiceProviderName( iStatus, iServiceProviderNamePckg ); |
|
295 SetActive(); |
|
296 break; |
|
297 // Some mysterious error |
|
298 default: |
|
299 LOGSTRING2( "Unknown network status code! %i", iRegisterationStatus ); |
|
300 LOGSTRING2( "ERegisteredOnHomeNetwork: %i", RMobilePhone::ERegisteredOnHomeNetwork ); |
|
301 User::Leave( KErrOverflow ); |
|
302 break; |
|
303 } |
|
304 break; |
|
305 } |
|
306 case ERequestingServiceProviderName: |
|
307 LOGSTRING( "ERequestingServiceProviderName" ); |
|
308 iMonitoringStatus = ERequestingHomeNetworkInfo; |
|
309 iPhone.GetHomeNetwork( iStatus, iHomeNetworkInfoPckg ); |
|
310 SetActive(); |
|
311 break; |
|
312 case ERequestingHomeNetworkInfo: |
|
313 LOGSTRING( "ERequestingHomeNetworkInfo" ); |
|
314 iMonitoringStatus = ERequestingCurrentNetworkInfo; |
|
315 |
|
316 // Use the override that does not need Location capability |
|
317 iPhone.GetCurrentNetwork( |
|
318 iStatus, |
|
319 iCurrentNetworkInfoPckg ); |
|
320 |
|
321 SetActive(); |
|
322 break; |
|
323 case ERequestingCurrentNetworkInfo: |
|
324 { |
|
325 LOGSTRING( "ERequestingCurrentNetworkInfo" ); |
|
326 iMonitoringStatus = ERequestingOwnNumberInfo; |
|
327 |
|
328 #ifdef __WINS__ |
|
329 TRequestStatus* status = &iStatus; |
|
330 User::RequestComplete( status, KErrNone ); |
|
331 #else |
|
332 TInt err; |
|
333 err = iONStore.Open( iPhone ); |
|
334 if (err != KErrNone) // error occured |
|
335 { |
|
336 LOGSTRING2( "iONStore.Open err: %i", err ); |
|
337 User::Leave( err ); |
|
338 } |
|
339 iOwnNumberInfo.iIndex = 0; |
|
340 iONStore.Read( iStatus, iOwnNumberInfoPckg ); |
|
341 #endif |
|
342 SetActive(); |
|
343 } |
|
344 break; |
|
345 case ERequestingOwnNumberInfo: |
|
346 { |
|
347 LOGSTRING( "ERequestingOwnNumberInfo" ); |
|
348 iMonitoringStatus = ERequestingPhoneIdentity; |
|
349 #ifdef __WINS__ |
|
350 TRequestStatus* status = &iStatus; |
|
351 User::RequestComplete( status, KErrNone ); |
|
352 #else |
|
353 iPhone.GetPhoneId( iStatus, iPhoneIdentity ); |
|
354 #endif |
|
355 SetActive(); |
|
356 } |
|
357 break; |
|
358 case ERequestingPhoneIdentity: |
|
359 LOGSTRING( "ERequestingPhoneIdentity" ); |
|
360 iMonitoringStatus = ERequestingIMSI; |
|
361 iPhone.GetSubscriberId( iStatus, iIMSI ); |
|
362 SetActive(); |
|
363 break; |
|
364 case ERequestingIMSI: |
|
365 LOGSTRING( "ERequestingIMSI" ); |
|
366 iMonitoringStatus = EDone; |
|
367 switch( iRegisterationStatus ) |
|
368 { |
|
369 case RMobilePhone::ERegisteredOnHomeNetwork: |
|
370 iNotifier.RegistrationMonitoringDoneL( EHomenetwork ); |
|
371 break; |
|
372 case RMobilePhone::ERegisteredRoaming: |
|
373 iNotifier.RegistrationMonitoringDoneL( ERoaming ); |
|
374 break; |
|
375 default: |
|
376 iNotifier.RegistrationMonitoringDoneL( EStatusUnknown ); |
|
377 break; |
|
378 } |
|
379 break; |
|
380 default: |
|
381 LOGSTRING( "default" ); |
|
382 User::Leave( KErrOverflow ); |
|
383 break; |
|
384 } |
|
385 */ |
|
386 } |
|
387 |
|
388 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
389 |
|
390 // None |
|
391 |
|
392 // End of File |