1 // Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of "Eclipse Public License v1.0" |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
49 /** |
43 /** |
50 * start initializing the phone |
44 * start initializing the phone |
51 */ |
45 */ |
52 void CSmsPhoneInitialization::Start() |
46 void CSmsPhoneInitialization::Start() |
53 { |
47 { |
54 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPHONEINITIALIZATION_START_1, "CSmsPhoneInitialization::Start Start initializing the phone"); |
48 LOGSMSPROT1("CSmsPhoneInitialization::Start Start initializing the phone"); |
55 |
49 |
56 Cancel(); |
50 Cancel(); |
57 |
51 |
58 iInitialized = KErrNotReady; |
52 iInitialized = KErrNotReady; |
59 iNetworkInfoAvailable =EFalse; |
53 iNetworkInfoAvailable =EFalse; |
64 } // CSmsPhoneInitialization::Start |
58 } // CSmsPhoneInitialization::Start |
65 |
59 |
66 |
60 |
67 void CSmsPhoneInitialization::DoRunL() |
61 void CSmsPhoneInitialization::DoRunL() |
68 { |
62 { |
69 OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPHONEINITIALIZATION_DORUNL_1, "CSmsPhoneInitialization::DoRunL [iStatus=%d, iState=%d]", iStatus.Int(), iState); |
63 LOGSMSPROT3("CSmsPhoneInitialization::DoRunL [iStatus=%d, iState=%d]", iStatus.Int(), iState); |
70 |
64 |
71 switch (iState) |
65 switch (iState) |
72 { |
66 { |
73 case ESmsPhoneInitializationPhoneInit: |
67 case ESmsPhoneInitializationPhoneInit: |
74 { |
68 { |
78 |
72 |
79 case ESmsPhoneInitializationSettingMoBearer: |
73 case ESmsPhoneInitializationSettingMoBearer: |
80 { |
74 { |
81 if (iStatus.Int() != KErrNone) |
75 if (iStatus.Int() != KErrNone) |
82 { |
76 { |
83 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPHONEINITIALIZATION_DORUNL_2, "ERROR - TSY failed to set bearer but initialisation will continue; bearer setting may be successful during send"); |
77 LOGSMSPROT1("ERROR - TSY failed to set bearer but initialisation will continue; bearer setting may be successful during send"); |
84 } |
78 } |
85 |
79 |
86 iState=ESmsPhoneInitializationGettingRegistrationStatus; |
80 iState=ESmsPhoneInitializationGettingRegistrationStatus; |
87 iGsmPhone.GetNetworkRegistrationStatus(iStatus, iRegistrationStatus); |
81 iGsmPhone.GetNetworkRegistrationStatus(iStatus, iRegistrationStatus); |
88 SetActive(); |
82 SetActive(); |
91 |
85 |
92 case ESmsPhoneInitializationGettingRegistrationStatus: |
86 case ESmsPhoneInitializationGettingRegistrationStatus: |
93 { |
87 { |
94 if(iStatus == KErrNone) |
88 if(iStatus == KErrNone) |
95 { |
89 { |
96 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPHONEINITIALIZATION_DORUNL_3, "CSmsPhoneInitialization::DoRunL registration status : >%d<",iRegistrationStatus); |
90 LOGSMSPROT2("CSmsPhoneInitialization::DoRunL registration status : >%d<",iRegistrationStatus); |
97 if (iRegistrationStatus==RMobilePhone::ERegisteredOnHomeNetwork || |
91 if (iRegistrationStatus==RMobilePhone::ERegisteredOnHomeNetwork || |
98 iRegistrationStatus == RMobilePhone::ERegisteredRoaming) |
92 iRegistrationStatus == RMobilePhone::ERegisteredRoaming) |
99 { |
93 { |
100 iState=ESmsPhoneInitializationGettingCurrentNetworkInfo; |
94 iState=ESmsPhoneInitializationGettingCurrentNetworkInfo; |
101 iGsmPhone.GetCurrentNetwork(iStatus, iNetworkInfoPckg); |
95 iGsmPhone.GetCurrentNetwork(iStatus, iNetworkInfoPckg); |
140 { |
134 { |
141 iState=ESmsPhoneInitializationCompleted; |
135 iState=ESmsPhoneInitializationCompleted; |
142 if(iStatus == KErrNone) |
136 if(iStatus == KErrNone) |
143 { |
137 { |
144 iNetworkInfoAvailable =ETrue; |
138 iNetworkInfoAvailable =ETrue; |
145 OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPHONEINITIALIZATION_DORUNL_6, "CSmsPhoneInitialization::DoRunL network longname : >%S<",iNetworkInfo.iLongName); |
139 LOGSMSPROT2("CSmsPhoneInitialization::DoRunL network longname : >%S<",&iNetworkInfo.iLongName); |
146 OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPHONEINITIALIZATION_DORUNL_7, "CSmsPhoneInitialization::DoRunL network shortname : >%S<",iNetworkInfo.iShortName); |
140 LOGSMSPROT2("CSmsPhoneInitialization::DoRunL network shortname : >%S<",&iNetworkInfo.iShortName); |
147 OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPHONEINITIALIZATION_DORUNL_8, "CSmsPhoneInitialization::DoRunL network shortname : >%S<",iNetworkInfo.iDisplayTag); |
141 LOGSMSPROT2("CSmsPhoneInitialization::DoRunL network shortname : >%S<",&iNetworkInfo.iDisplayTag); |
148 } |
142 } |
149 else |
143 else |
150 { |
144 { |
151 iNetworkInfoAvailable =EFalse; |
145 iNetworkInfoAvailable =EFalse; |
152 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPHONEINITIALIZATION_DORUNL_9, "CSmsPhoneInitialization::DoRunL NETWORK INFO NOT available due %d",iStatus.Int()); |
146 LOGSMSPROT2("CSmsPhoneInitialization::DoRunL NETWORK INFO NOT available due %d",iStatus.Int()); |
153 } |
147 } |
154 iSmsPDURead.Start(); |
148 iSmsPDURead.Start(); |
155 } |
149 } |
156 break; |
150 break; |
157 |
151 |
172 /** |
166 /** |
173 * cancel the initialization |
167 * cancel the initialization |
174 */ |
168 */ |
175 void CSmsPhoneInitialization::DoCancel() |
169 void CSmsPhoneInitialization::DoCancel() |
176 { |
170 { |
177 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPHONEINITIALIZATION_DOCANCEL_1, "CSmsPhoneInitialization::DoCancel()"); |
171 LOGSMSPROT1("CSmsPhoneInitialization::DoCancel()"); |
178 |
172 |
179 switch (iState) |
173 switch (iState) |
180 { |
174 { |
181 case ESmsPhoneInitializationPhoneInit: |
175 case ESmsPhoneInitializationPhoneInit: |
182 { |
176 { |
231 * |
225 * |
232 * @param aStatus a status value |
226 * @param aStatus a status value |
233 */ |
227 */ |
234 void CSmsPhoneInitialization::Complete(TInt aStatus) |
228 void CSmsPhoneInitialization::Complete(TInt aStatus) |
235 { |
229 { |
236 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPHONEINITIALIZATION_COMPLETE_1, "CSmsPhoneInitialization::Complete()"); |
230 LOGSMSPROT1("CSmsPhoneInitialization::Complete()"); |
237 |
231 |
238 // |
232 // |
239 // Call the base function to perform the actual complete... |
233 // Call the base function to perform the actual complete... |
240 // |
234 // |
241 CSmsuActiveBase::Complete(aStatus); |
235 CSmsuActiveBase::Complete(aStatus); |
249 * @param aStatus An error code indicating the status returned on the |
243 * @param aStatus An error code indicating the status returned on the |
250 * previous call to RPhone::Initialise(). |
244 * previous call to RPhone::Initialise(). |
251 */ |
245 */ |
252 void CSmsPhoneInitialization::AfterPhoneInitialize(TInt aStatus) |
246 void CSmsPhoneInitialization::AfterPhoneInitialize(TInt aStatus) |
253 { |
247 { |
254 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPHONEINITIALIZATION_AFTERPHONEINITIALIZE_1, "CSmsPhoneInitialization::AfterPhoneIntialize [status=%d]", aStatus); |
248 LOGSMSPROT2("CSmsPhoneInitialization::AfterPhoneIntialize [status=%d]", aStatus); |
255 |
249 |
256 if (aStatus == KErrNone) |
250 if (aStatus == KErrNone) |
257 { |
251 { |
258 RMobileSmsMessaging::TMobileSmsCapsV1Pckg smsCapsPckg(iMobileSmsCaps); |
252 RMobileSmsMessaging::TMobileSmsCapsV1Pckg smsCapsPckg(iMobileSmsCaps); |
259 aStatus = iSmsMessaging.GetCaps(smsCapsPckg); |
253 aStatus = iSmsMessaging.GetCaps(smsCapsPckg); |
261 |
255 |
262 if (aStatus == KErrNone) |
256 if (aStatus == KErrNone) |
263 { |
257 { |
264 if (iMobileSmsCaps.iSmsMode != RMobileSmsMessaging::KCapsGsmSms) |
258 if (iMobileSmsCaps.iSmsMode != RMobileSmsMessaging::KCapsGsmSms) |
265 { |
259 { |
266 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPHONEINITIALIZATION_AFTERPHONEINITIALIZE_2, "TSY does not support GsmSms"); |
260 LOGSMSPROT1("TSY does not support GsmSms"); |
267 aStatus = KErrNotSupported; |
261 aStatus = KErrNotSupported; |
268 } |
262 } |
269 else |
263 else |
270 { |
264 { |
271 // Initialisation of phone is complete and phone supports GSM SMS. |
265 // Initialisation of phone is complete and phone supports GSM SMS. |
277 } |
271 } |
278 else |
272 else |
279 { |
273 { |
280 if (++iNumberOfAttempts < iMaxNumberOfAttempts) |
274 if (++iNumberOfAttempts < iMaxNumberOfAttempts) |
281 { |
275 { |
282 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPHONEINITIALIZATION_AFTERPHONEINITIALIZE_3, "CSmsPhoneInitialization Restarting [aStatus=%d]", aStatus); |
276 LOGSMSPROT2("CSmsPhoneInitialization Restarting [aStatus=%d]", aStatus); |
283 iGsmPhone.Initialise(iStatus); |
277 iGsmPhone.Initialise(iStatus); |
284 SetActive(); |
278 SetActive(); |
285 } |
279 } |
286 else |
280 else |
287 { |
281 { |
288 OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPHONEINITIALIZATION_AFTERPHONEINITIALIZE_4, "CSmsPhoneInitialization Failed after %d attempts [aStatus=%d]", iNumberOfAttempts, aStatus); |
282 LOGSMSPROT3("CSmsPhoneInitialization Failed after %d attempts [aStatus=%d]", iNumberOfAttempts, aStatus); |
289 } |
283 } |
290 } |
284 } |
291 |
285 |
292 iInitialized = aStatus; |
286 iInitialized = aStatus; |
293 } // CSmsPhoneInitialization::AfterPhoneInitialize |
287 } // CSmsPhoneInitialization::AfterPhoneInitialize |
318 /** |
312 /** |
319 * 2 phase constructor - safely create a CSmsModemNotification object |
313 * 2 phase constructor - safely create a CSmsModemNotification object |
320 */ |
314 */ |
321 CSmsModemNotification* CSmsModemNotification::NewL(MSmsComm& aSmsComm) |
315 CSmsModemNotification* CSmsModemNotification::NewL(MSmsComm& aSmsComm) |
322 { |
316 { |
323 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMODEMNOTIFICATION_NEWL_1, "CSmsModemNotification::NewL"); |
317 LOGSMSPROT1("CSmsModemNotification::NewL"); |
324 |
318 |
325 CSmsModemNotification* self=new(ELeave) CSmsModemNotification(aSmsComm); |
319 CSmsModemNotification* self=new(ELeave) CSmsModemNotification(aSmsComm); |
326 CleanupStack::PushL(self); |
320 CleanupStack::PushL(self); |
327 self->ConstructL(); |
321 self->ConstructL(); |
328 CleanupStack::Pop(self); |
322 CleanupStack::Pop(self); |
331 } // CSmsModemNotification::NewL |
325 } // CSmsModemNotification::NewL |
332 |
326 |
333 |
327 |
334 void CSmsModemNotification::ConstructL() |
328 void CSmsModemNotification::ConstructL() |
335 { |
329 { |
336 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMODEMNOTIFICATION_CONSTRUCTL_1, "CSmsModemNotification::ConstructL()"); |
330 LOGSMSPROT1("CSmsModemNotification::ConstructL()"); |
337 |
331 |
338 User::LeaveIfError(iPhonePowerProperty.Attach(KUidSystemCategory, KUidPhonePwr.iUid)); |
332 User::LeaveIfError(iPhonePowerProperty.Attach(KUidSystemCategory, KUidPhonePwr.iUid)); |
339 |
333 |
340 ConstructTimeoutL(); |
334 ConstructTimeoutL(); |
341 } // CSmsModemNotification::ConstructL |
335 } // CSmsModemNotification::ConstructL |
351 } // CSmsModemNotification::~CSmsModemNotification |
345 } // CSmsModemNotification::~CSmsModemNotification |
352 |
346 |
353 |
347 |
354 RPhone::TModemDetection CSmsModemNotification::ModemState() |
348 RPhone::TModemDetection CSmsModemNotification::ModemState() |
355 { |
349 { |
356 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMODEMNOTIFICATION_MODEMSTATE_1, "CSmsModemNotification::ModemState()"); |
350 LOGSMSPROT1("CSmsModemNotification::ModemState()"); |
357 |
351 |
358 // |
352 // |
359 // Get the phone power state. |
353 // Get the phone power state. |
360 // |
354 // |
361 TInt phonePowerState; |
355 TInt phonePowerState; |
379 /** |
373 /** |
380 * start the modem notification |
374 * start the modem notification |
381 */ |
375 */ |
382 void CSmsModemNotification::Start() |
376 void CSmsModemNotification::Start() |
383 { |
377 { |
384 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMODEMNOTIFICATION_START_1, "CSmsModemNotification::Start"); |
378 LOGSMSPROT1("CSmsModemNotification::Start"); |
385 |
379 |
386 __ASSERT_DEBUG(iState==ESmsModemNotificationIdle,SmspPanic(KSmspPanicUnexpectedState)); |
380 __ASSERT_DEBUG(iState==ESmsModemNotificationIdle,SmspPanic(KSmspPanicUnexpectedState)); |
387 |
381 |
388 // |
382 // |
389 // Subscribe to the power property... |
383 // Subscribe to the power property... |
398 /** |
392 /** |
399 * asyncronous completion - called by ActiveScheduler when modem notification completed |
393 * asyncronous completion - called by ActiveScheduler when modem notification completed |
400 */ |
394 */ |
401 void CSmsModemNotification::DoRunL() |
395 void CSmsModemNotification::DoRunL() |
402 { |
396 { |
403 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMODEMNOTIFICATION_DORUNL_1, "CSmsModemNotification::RunL [iStatus=%d]", iStatus.Int() ); |
397 LOGSMSPROT2("CSmsModemNotification::RunL [iStatus=%d]", iStatus.Int() ); |
404 |
398 |
405 __ASSERT_DEBUG(iState==ESmsModemNotificationWaitingForNotification,SmspPanic(KSmspPanicUnexpectedState)); |
399 __ASSERT_DEBUG(iState==ESmsModemNotificationWaitingForNotification,SmspPanic(KSmspPanicUnexpectedState)); |
406 |
400 |
407 // |
401 // |
408 // DoRunL() will now return to CSmsuActiveBase which if the object |
402 // DoRunL() will now return to CSmsuActiveBase which if the object |
414 /** |
408 /** |
415 * cancel the modem notification |
409 * cancel the modem notification |
416 */ |
410 */ |
417 void CSmsModemNotification::DoCancel() |
411 void CSmsModemNotification::DoCancel() |
418 { |
412 { |
419 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMODEMNOTIFICATION_DOCANCEL_1, "CSmsModemNotification::DoCancel()"); |
413 LOGSMSPROT1("CSmsModemNotification::DoCancel()"); |
420 |
414 |
421 __ASSERT_DEBUG(iState==ESmsModemNotificationWaitingForNotification,SmspPanic(KSmspPanicUnexpectedState)); |
415 __ASSERT_DEBUG(iState==ESmsModemNotificationWaitingForNotification,SmspPanic(KSmspPanicUnexpectedState)); |
422 |
416 |
423 // |
417 // |
424 // Cancel the request... |
418 // Cancel the request... |
454 /** |
448 /** |
455 * complete the modem notification - inform the observer |
449 * complete the modem notification - inform the observer |
456 */ |
450 */ |
457 void CSmsModemNotification::Complete(TInt aStatus) |
451 void CSmsModemNotification::Complete(TInt aStatus) |
458 { |
452 { |
459 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMODEMNOTIFICATION_COMPLETE_1, "CSmsModemNotification::Complete()"); |
453 LOGSMSPROT1("CSmsModemNotification::Complete()"); |
460 |
454 |
461 // |
455 // |
462 // Call the base function to perform the actual complete... |
456 // Call the base function to perform the actual complete... |
463 // |
457 // |
464 CSmsuActiveBase::Complete(aStatus); |
458 CSmsuActiveBase::Complete(aStatus); |