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