smsprotocols/smsstack/smsprot/Src/smsprot.cpp
branchRCL_3
changeset 66 07a122eea281
parent 65 630d2f34d719
equal deleted inserted replaced
65:630d2f34d719 66:07a122eea281
     1 // Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2003-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".
    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 "smsprotTraces.h"
       
    26 #endif
       
    27 
       
    28 #include <commsdattypesv1_1.h>
    22 #include <commsdattypesv1_1.h>
    29 #include <logwrap.h>
    23 #include <logwrap.h>
    30 #include "Gsmumsg.h"
    24 #include "Gsmumsg.h"
    31 #include "gsmubuf.h"
    25 #include "gsmubuf.h"
    32 #include "Gsmuelem.h"
    26 #include "Gsmuelem.h"
    66  *  2 phase constructor
    60  *  2 phase constructor
    67  *  
    61  *  
    68  */
    62  */
    69 CSmsProtocolFamily * CSmsProtocolFamily::NewL()
    63 CSmsProtocolFamily * CSmsProtocolFamily::NewL()
    70 	{
    64 	{
    71     OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOLFAMILY_NEWL_1, "CSmsProtocolFamily::NewL [version %u.%u.%u]",KSmsPrtMajorVersionNumber,KSmsPrtMinorVersionNumber,KSmsPrtBuildVersionNumber );
    65 	LOGSMSPROT4("CSmsProtocolFamily::NewL [version %d.%d.%d]",
       
    66 			 KSmsPrtMajorVersionNumber,
       
    67 			 KSmsPrtMinorVersionNumber,
       
    68 			 KSmsPrtBuildVersionNumber
       
    69 			 );
    72 	return new (ELeave)CSmsProtocolFamily;
    70 	return new (ELeave)CSmsProtocolFamily;
    73 	} // CSmsProtocolFamily::NewL
    71 	} // CSmsProtocolFamily::NewL
    74 
    72 
    75 
    73 
    76 /**
    74 /**
    79  *  Does nothing.
    77  *  Does nothing.
    80  *  
    78  *  
    81  */
    79  */
    82 TInt CSmsProtocolFamily::Install()
    80 TInt CSmsProtocolFamily::Install()
    83 	{
    81 	{
    84 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOLFAMILY_INSTALL_1, "CSmsProtocolFamily::Install");
    82 	LOGSMSPROT1("CSmsProtocolFamily::Install");
    85 	return KErrNone;
    83 	return KErrNone;
    86 	} // CProtocolFamilyBase::Install
    84 	} // CProtocolFamilyBase::Install
    87 
    85 
    88 
    86 
    89 /**
    87 /**
    93  *  Does nothing.
    91  *  Does nothing.
    94  *  
    92  *  
    95  */
    93  */
    96 TInt CSmsProtocolFamily::Remove()
    94 TInt CSmsProtocolFamily::Remove()
    97 	{
    95 	{
    98 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOLFAMILY_REMOVE_1, "CSmsProtocolFamily::Remove");
    96 	LOGSMSPROT1("CSmsProtocolFamily::Remove");
    99 	return KErrNone;
    97 	return KErrNone;
   100 	} // CProtocolFamilyBase::Remove
    98 	} // CProtocolFamilyBase::Remove
   101 
    99 
   102 
   100 
   103 /**
   101 /**
   109  *  @return a new instance of the CSmsProtocol class.
   107  *  @return a new instance of the CSmsProtocol class.
   110  *  
   108  *  
   111  */
   109  */
   112 CProtocolBase * CSmsProtocolFamily::NewProtocolL(TUint /*aSockType*/,TUint /*aProtocol*/)
   110 CProtocolBase * CSmsProtocolFamily::NewProtocolL(TUint /*aSockType*/,TUint /*aProtocol*/)
   113 	{
   111 	{
   114 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOLFAMILY_NEWPROTOCOLL_1	        , "CSmsProtocolFamily::NewProtocolL");
   112 	LOGSMSPROT1("CSmsProtocolFamily::NewProtocolL");
   115 	return CSmsProtocol::NewL();
   113 	return CSmsProtocol::NewL();
   116 	} // CProtocolFamilyBase::NewProtocolL
   114 	} // CProtocolFamilyBase::NewProtocolL
   117 
   115 
   118 
   116 
   119 /**
   117 /**
   127  *  @return the number of protocols supported (1).
   125  *  @return the number of protocols supported (1).
   128  *  
   126  *  
   129  */
   127  */
   130 TUint CSmsProtocolFamily::ProtocolList(TServerProtocolDesc *& aProtocolList)
   128 TUint CSmsProtocolFamily::ProtocolList(TServerProtocolDesc *& aProtocolList)
   131 	{
   129 	{
   132 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOLFAMILY_PROTOCOLLIST_1, "CSmsProtocolFamily::ProtocolList");
   130 	LOGSMSPROT1("CSmsProtocolFamily::ProtocolList");
   133 
   131 
   134 	TRAPD(ret, (aProtocolList=new(ELeave) TServerProtocolDesc[1]));
   132 	TRAPD(ret, (aProtocolList=new(ELeave) TServerProtocolDesc[1]));
   135 	if(ret!=KErrNone)
   133 	if(ret!=KErrNone)
   136 		{
   134 		{
   137 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOLFAMILY_PROTOCOLLIST_2, "WARNING! new TServerProtocolDesc left with %d", ret);
   135 		LOGSMSPROT2("WARNING! new TServerProtocolDesc left with %d", ret);
   138 		return 0;
   136 		return 0;
   139 		}
   137 		}
   140 
   138 
   141 	// Datagram protocol
   139 	// Datagram protocol
   142 	aProtocolList[0].iName=KSmsDatagram;
   140 	aProtocolList[0].iName=KSmsDatagram;
   169  *  an instance of our CProtocolFamilyBase derived class.
   167  *  an instance of our CProtocolFamilyBase derived class.
   170  *  
   168  *  
   171  */
   169  */
   172 EXPORT_C CProtocolFamilyBase* InstallSMS()
   170 EXPORT_C CProtocolFamilyBase* InstallSMS()
   173 	{
   171 	{
   174 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, INSTALLSMS_1, "CSmsProtocolFamily::CSmsProtocolFamily()");
   172 	LOGSMSPROT1("CSmsProtocolFamily::CSmsProtocolFamily()");
   175 
   173 
   176 	CSmsProtocolFamily*  smsProtocolFamily(NULL);
   174 	CSmsProtocolFamily*  smsProtocolFamily(NULL);
   177 	
   175 	
   178 	TRAP_IGNORE(smsProtocolFamily = CSmsProtocolFamily::NewL());
   176 	TRAP_IGNORE(smsProtocolFamily = CSmsProtocolFamily::NewL());
   179 
   177 
   190  *  2 phase constructor.
   188  *  2 phase constructor.
   191  *  
   189  *  
   192  */
   190  */
   193 CSmsProtocol* CSmsProtocol::NewL()
   191 CSmsProtocol* CSmsProtocol::NewL()
   194 	{
   192 	{
   195 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_NEWL_1, "CSmsProtocol::NewL()");
   193 	LOGSMSPROT1("CSmsProtocol::NewL()");
   196 
   194 
   197 	return new (ELeave) CSmsProtocol();
   195 	return new (ELeave) CSmsProtocol();
   198 	} // CSmsProtocol::NewL
   196 	} // CSmsProtocol::NewL
   199 
   197 
   200 
   198 
   252  *  @return a new CSmsProvider object.
   250  *  @return a new CSmsProvider object.
   253  *  
   251  *  
   254  */
   252  */
   255 CServProviderBase *CSmsProtocol::NewSAPL(TUint aSocketType)
   253 CServProviderBase *CSmsProtocol::NewSAPL(TUint aSocketType)
   256 	{
   254 	{
   257 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_NEWSAPL_1, "*CSmsProtocol::NewSAPL [sockettype=%d]", aSocketType);
   255 	LOGSMSPROT2("*CSmsProtocol::NewSAPL [sockettype=%d]", aSocketType);
   258 	if (aSocketType!=KSockDatagram)
   256 	if (aSocketType!=KSockDatagram)
   259 		User::Leave(KErrNotSupported);
   257 		User::Leave(KErrNotSupported);
   260 	return CSmsProvider::NewL(*this);
   258 	return CSmsProvider::NewL(*this);
   261 	} // CProtocolBase::NewSAPL
   259 	} // CProtocolBase::NewSAPL
   262 
   260 
   274  *  state machines started (otherwise wait until we receive notification of connection).
   272  *  state machines started (otherwise wait until we receive notification of connection).
   275  *  
   273  *  
   276  */
   274  */
   277 void CSmsProtocol::InitL(TDesC& /*aTag*/)
   275 void CSmsProtocol::InitL(TDesC& /*aTag*/)
   278 	{
   276 	{
   279 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_INITL_1, "CSmsProtocol::InitL");
   277 	LOGSMSPROT1("CSmsProtocol::InitL");
   280 
   278 
   281 	User::LeaveIfError(iFs.Connect());
   279 	User::LeaveIfError(iFs.Connect());
   282 
   280 
   283 	iReassemblyStore=CFacadeSmsReassemblyStore::NewL(iFs, *this);
   281 	iReassemblyStore=CFacadeSmsReassemblyStore::NewL(iFs, *this);
   284 	iReassemblyStore->InitL();
   282 	iReassemblyStore->InitL();
   285 
   283 
   286 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_INITL_2, "CSmsProtocol::InitL Constructing members");
   284 	LOGSMSPROT1("CSmsProtocol::InitL Constructing members");
   287 
   285 
   288 	ReadConfigurableSettingsL();
   286 	ReadConfigurableSettingsL();
   289 
   287 
   290 	iBootTimer = CSmsProtocolBootTimer::NewL(*this);
   288 	iBootTimer = CSmsProtocolBootTimer::NewL(*this);
   291 	iBootTimer->Start(iSmsSettings.BootTimerTimeout().Int());
   289 	iBootTimer->Start(iSmsSettings.BootTimerTimeout().Int());
   315 	TInt ret=StartC32();
   313 	TInt ret=StartC32();
   316 	if (ret!=KErrAlreadyExists)
   314 	if (ret!=KErrAlreadyExists)
   317 		User::LeaveIfError(ret);
   315 		User::LeaveIfError(ret);
   318 #endif
   316 #endif
   319 */
   317 */
   320 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_INITL_3, "CSmsProtocol::InitL Querying CommDb");
   318 	LOGSMSPROT1("CSmsProtocol::InitL Querying CommDb");
   321 
   319 
   322 	// Read the global modem ID setting from  Cooms Database
   320 	// Read the global modem ID setting from  Cooms Database
   323 	TUint32 modemId = 0;
   321 	TUint32 modemId = 0;
   324 
   322 
   325 	
   323 	
   344 	iGsmTsyName = *tsyField;
   342 	iGsmTsyName = *tsyField;
   345 	CleanupStack::PopAndDestroy(tsyField);
   343 	CleanupStack::PopAndDestroy(tsyField);
   346 
   344 
   347 	CleanupStack::PopAndDestroy(sess);
   345 	CleanupStack::PopAndDestroy(sess);
   348 
   346 
   349     OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_INITL_4, "CSmsProtocol::InitL [modemId=%d tsy=%S]",(TInt)modemId, iGsmTsyName );
   347 #ifdef _SMS_LOGGING_ENABLED
       
   348 	TBuf8<KCommsDbSvrMaxFieldLength> buf8;
       
   349 	buf8.Copy(iGsmTsyName);
       
   350 	LOGSMSPROT3("CSmsProtocol::InitL [modemId=%d tsy=%S]",
       
   351 				modemId, &buf8);
       
   352 #endif
   350 
   353 
   351 	// Start event notification state machines
   354 	// Start event notification state machines
   352 	iSmsModemNotification->Start();
   355 	iSmsModemNotification->Start();
   353 
   356 
   354 	// Intialise the SmsStack to the state that the phone has been found in
   357 	// Intialise the SmsStack to the state that the phone has been found in
   391  *  Binding is not supported so this indication is not important to us.
   394  *  Binding is not supported so this indication is not important to us.
   392  *  
   395  *  
   393  */
   396  */
   394 void CSmsProtocol::StartL(void)
   397 void CSmsProtocol::StartL(void)
   395 	{
   398 	{
   396 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_STARTL_1, "CSmsProtocol::StartL");
   399 	LOGSMSPROT1("CSmsProtocol::StartL");
   397 	} // CSmsProtocol::StartL
   400 	} // CSmsProtocol::StartL
   398 
   401 
   399 
   402 
   400 /**
   403 /**
   401  *  Override of CProtocolBase::Identify().
   404  *  Override of CProtocolBase::Identify().
   402  *  Called by the socket server to obtain a description of the SMS protocol.
   405  *  Called by the socket server to obtain a description of the SMS protocol.
   403  *  
   406  *  
   404  */
   407  */
   405 void CSmsProtocol::Identify(TServerProtocolDesc *aDesc)const
   408 void CSmsProtocol::Identify(TServerProtocolDesc *aDesc)const
   406 	{
   409 	{
   407 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_IDENTIFY_1, "CSmsProtocol::Identify");
   410 	LOGSMSPROT1("CSmsProtocol::Identify");
   408 
   411 
   409 	aDesc->iName=KSmsDatagram;
   412 	aDesc->iName=KSmsDatagram;
   410 	aDesc->iAddrFamily=KSMSAddrFamily;
   413 	aDesc->iAddrFamily=KSMSAddrFamily;
   411 	aDesc->iSockType=KSockDatagram;
   414 	aDesc->iSockType=KSockDatagram;
   412 	aDesc->iProtocol=KSMSDatagramProtocol;
   415 	aDesc->iProtocol=KSMSDatagramProtocol;
   431  */
   434  */
   432 CHostResolvProvdBase *CSmsProtocol::NewHostResolverL()
   435 CHostResolvProvdBase *CSmsProtocol::NewHostResolverL()
   433     {
   436     {
   434     // Ignore in code coverage - not intended to be used
   437     // Ignore in code coverage - not intended to be used
   435     BULLSEYE_OFF    
   438     BULLSEYE_OFF    
   436     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_NEWHOSTRESOLVERL_1, "CSmsProtocol::NewHostResolverL");
   439     LOGSMSPROT1("CSmsProtocol::NewHostResolverL");
   437     SmspPanic(ESmspCantCreateHostResolver);
   440     SmspPanic(ESmspCantCreateHostResolver);
   438     return NULL;
   441     return NULL;
   439     BULLSEYE_RESTORE
   442     BULLSEYE_RESTORE
   440     }
   443     }
   441 
   444 
   449  */
   452  */
   450 CServiceResolvProvdBase *CSmsProtocol::NewServiceResolverL()
   453 CServiceResolvProvdBase *CSmsProtocol::NewServiceResolverL()
   451     {
   454     {
   452     // Ignore in code coverage - not intended to be used
   455     // Ignore in code coverage - not intended to be used
   453     BULLSEYE_OFF    
   456     BULLSEYE_OFF    
   454     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_NEWSERVICERESOLVERL_1, "*CSmsProtocol::NewServiceResolverL");
   457     LOGSMSPROT1("*CSmsProtocol::NewServiceResolverL");
   455     SmspPanic(ESmspCantCreateServiceResolver);
   458     SmspPanic(ESmspCantCreateServiceResolver);
   456     return NULL;
   459     return NULL;
   457     BULLSEYE_RESTORE
   460     BULLSEYE_RESTORE
   458     }
   461     }
   459 
   462 
   467  */
   470  */
   468 CNetDBProvdBase* CSmsProtocol::NewNetDatabaseL()
   471 CNetDBProvdBase* CSmsProtocol::NewNetDatabaseL()
   469     {
   472     {
   470     // Ignore in code coverage - not intended to be used
   473     // Ignore in code coverage - not intended to be used
   471     BULLSEYE_OFF    
   474     BULLSEYE_OFF    
   472     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_NEWNETDATABASEL_1, "CSmsProtocol::NewNetDatabaseL");
   475     LOGSMSPROT1("CSmsProtocol::NewNetDatabaseL");
   473     SmspPanic(ESmspCantCreateNetDatabase);
   476     SmspPanic(ESmspCantCreateNetDatabase);
   474     return NULL;
   477     return NULL;
   475     BULLSEYE_RESTORE
   478     BULLSEYE_RESTORE
   476     }
   479     }
   477 
   480 
   485  */
   488  */
   486 void CSmsProtocol::BindL(CProtocolBase* /*aProtocol*/,TUint /*aId*/)
   489 void CSmsProtocol::BindL(CProtocolBase* /*aProtocol*/,TUint /*aId*/)
   487     {
   490     {
   488     // Ignore in code coverage - not intended to be used
   491     // Ignore in code coverage - not intended to be used
   489     BULLSEYE_OFF    
   492     BULLSEYE_OFF    
   490     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_BINDL_1, "CSmsProtocol::BindL");
   493     LOGSMSPROT1("CSmsProtocol::BindL");
   491     SmspPanic(ESmspCantBind);
   494     SmspPanic(ESmspCantBind);
   492     BULLSEYE_RESTORE
   495     BULLSEYE_RESTORE
   493     }
   496     }
   494 
   497 
   495 /**
   498 /**
   503  */
   506  */
   504 void CSmsProtocol::BindToL(CProtocolBase* /*aProtocol*/)
   507 void CSmsProtocol::BindToL(CProtocolBase* /*aProtocol*/)
   505     {
   508     {
   506     // Ignore in code coverage - not intended to be used
   509     // Ignore in code coverage - not intended to be used
   507     BULLSEYE_OFF    
   510     BULLSEYE_OFF    
   508     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_BINDTOL_1, "CSmsProtocol::BindToL");
   511     LOGSMSPROT1("CSmsProtocol::BindToL");
   509     SmspPanic(ESmspCantBindTo);
   512     SmspPanic(ESmspCantBindTo);
   510     BULLSEYE_RESTORE
   513     BULLSEYE_RESTORE
   511     }
   514     }
   512 
   515 
   513 /**
   516 /**
   520 	{
   523 	{
   521 	CESockIniData* ini = NULL;
   524 	CESockIniData* ini = NULL;
   522 	TRAPD(ret, ini=CESockIniData::NewL(_L("smswap.sms.esk")));
   525 	TRAPD(ret, ini=CESockIniData::NewL(_L("smswap.sms.esk")));
   523 	if(ret!=KErrNone)
   526 	if(ret!=KErrNone)
   524 		{
   527 		{
   525 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_READCONFIGURABLESETTINGSL_1, "esk read failed, error code = [%d]", ret);
   528 		LOGSMSPROT2("esk read failed, error code = [%d]", ret);
   526 		User::Leave(ret);
   529 		User::Leave(ret);
   527 		}
   530 		}
   528 
   531 
   529 	CleanupStack::PushL(ini);
   532 	CleanupStack::PushL(ini);
   530 
   533 
   531 	TInt var(0);
   534 	TInt var(0);
   532 	if(ini->FindVar(_L("customTimeoutSettings"),_L("sendTryTimeout"),var))
   535 	if(ini->FindVar(_L("customTimeoutSettings"),_L("sendTryTimeout"),var))
   533 		{
   536 		{
   534 		if (var > 0)
   537 		if (var > 0)
   535 			{
   538 			{
   536 			OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_READCONFIGURABLESETTINGSL_2, "sendTryTimeout [%d]", var);
   539 			LOGSMSPROT2("sendTryTimeout [%d]", var);
   537 			iSmsSettings.SetSendTryTimeout(var);
   540 			iSmsSettings.SetSendTryTimeout(var);
   538 			}
   541 			}
   539 		else
   542 		else
   540 			{
   543 			{
   541 			User::Leave(KErrArgument);
   544 			User::Leave(KErrArgument);
   544 
   547 
   545 	if(ini->FindVar(_L("customTimeoutSettings"),_L("bootTimerTimeout"),var))
   548 	if(ini->FindVar(_L("customTimeoutSettings"),_L("bootTimerTimeout"),var))
   546 		{
   549 		{
   547 		if (var > 0)
   550 		if (var > 0)
   548 			{
   551 			{
   549 			OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_READCONFIGURABLESETTINGSL_3, "bootTimerTimeout [%d]", var);
   552 			LOGSMSPROT2("bootTimerTimeout [%d]", var);
   550 			iSmsSettings.SetBootTimerTimeout(var);
   553 			iSmsSettings.SetBootTimerTimeout(var);
   551 			}
   554 			}
   552 		else
   555 		else
   553 			{
   556 			{
   554 			User::Leave(KErrArgument);
   557 			User::Leave(KErrArgument);
   569  */
   572  */
   570 TInt CSmsProtocol::Send(TDes8& /*aDes*/,TSockAddr* /*aTo*/,TSockAddr* /*aFrom*/,CProtocolBase* /*aSourceProtocol*/)
   573 TInt CSmsProtocol::Send(TDes8& /*aDes*/,TSockAddr* /*aTo*/,TSockAddr* /*aFrom*/,CProtocolBase* /*aSourceProtocol*/)
   571     {
   574     {
   572     // Ignore in code coverage - not intended to be used
   575     // Ignore in code coverage - not intended to be used
   573     BULLSEYE_OFF    
   576     BULLSEYE_OFF    
   574     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_SEND_1, "CSmsProtocol::Send");
   577     LOGSMSPROT1("CSmsProtocol::Send");
   575     SmspPanic(ESmspCantSend);
   578     SmspPanic(ESmspCantSend);
   576     return KErrNotSupported;
   579     return KErrNotSupported;
   577     BULLSEYE_RESTORE
   580     BULLSEYE_RESTORE
   578     }
   581     }
   579 
   582 
   587  */
   590  */
   588 void CSmsProtocol::Process(TDes8& /*aDes*/,TSockAddr* /*aFrom*/,TSockAddr* /*aTo*/,CProtocolBase* /*aSourceProtocol*/)
   591 void CSmsProtocol::Process(TDes8& /*aDes*/,TSockAddr* /*aFrom*/,TSockAddr* /*aTo*/,CProtocolBase* /*aSourceProtocol*/)
   589     {
   592     {
   590     // Ignore in code coverage - not intended to be used
   593     // Ignore in code coverage - not intended to be used
   591     BULLSEYE_OFF    
   594     BULLSEYE_OFF    
   592     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_PROCESS_1, "CSmsProtocol::Process");
   595     LOGSMSPROT1("CSmsProtocol::Process");
   593     SmspPanic(ESmspCantProcess);
   596     SmspPanic(ESmspCantProcess);
   594     BULLSEYE_RESTORE
   597     BULLSEYE_RESTORE
   595     }
   598     }
   596 
   599 
   597 /**
   600 /**
   604  */
   607  */
   605 TInt CSmsProtocol::GetOption(TUint /*aLevel*/,TUint /*aName*/,TDes8 & /*aOption*/,CProtocolBase* /*aSourceProtocol*/)
   608 TInt CSmsProtocol::GetOption(TUint /*aLevel*/,TUint /*aName*/,TDes8 & /*aOption*/,CProtocolBase* /*aSourceProtocol*/)
   606     {
   609     {
   607     // Ignore in code coverage - not intended to be used
   610     // Ignore in code coverage - not intended to be used
   608     BULLSEYE_OFF    
   611     BULLSEYE_OFF    
   609     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_GETOPTION_1, "CSmsProtocol::GetOption");
   612     LOGSMSPROT1("CSmsProtocol::GetOption");
   610     // SmspPanic(ESmspCantGetOption);
   613     // SmspPanic(ESmspCantGetOption);
   611     return KErrNotSupported;
   614     return KErrNotSupported;
   612     BULLSEYE_RESTORE
   615     BULLSEYE_RESTORE
   613     }
   616     }
   614 
   617 
   622  */
   625  */
   623 TInt CSmsProtocol::SetOption(TUint /*aLevel*/,TUint /*aName*/,const TDesC8& /*option*/,CProtocolBase* /*aSourceProtocol*/)
   626 TInt CSmsProtocol::SetOption(TUint /*aLevel*/,TUint /*aName*/,const TDesC8& /*option*/,CProtocolBase* /*aSourceProtocol*/)
   624     {
   627     {
   625     // Ignore in code coverage - not intended to be used
   628     // Ignore in code coverage - not intended to be used
   626     BULLSEYE_OFF    
   629     BULLSEYE_OFF    
   627     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_SETOPTION_1, "CSmsProtocol::SetOption");
   630     LOGSMSPROT1("CSmsProtocol::SetOption");
   628     //SmspPanic(ESmspCantSetOption);
   631     //SmspPanic(ESmspCantSetOption);
   629     return KErrNotSupported;
   632     return KErrNotSupported;
   630     BULLSEYE_RESTORE
   633     BULLSEYE_RESTORE
   631     }
   634     }
   632 
   635 
   640  */
   643  */
   641 void CSmsProtocol::Error(TInt /*aError*/,CProtocolBase* /*aSourceProtocol*/)
   644 void CSmsProtocol::Error(TInt /*aError*/,CProtocolBase* /*aSourceProtocol*/)
   642     {
   645     {
   643     // Ignore in code coverage - not intended to be used
   646     // Ignore in code coverage - not intended to be used
   644     BULLSEYE_OFF    
   647     BULLSEYE_OFF    
   645     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_ERROR_1, "CSmsProtocol::Error");
   648     LOGSMSPROT1("CSmsProtocol::Error");
   646     SmspPanic(ESmspCantError);
   649     SmspPanic(ESmspCantError);
   647     BULLSEYE_RESTORE
   650     BULLSEYE_RESTORE
   648     }
   651     }
   649 
   652 
   650 /**
   653 /**
   654  *  @leave Leaves if not enough memory is available.
   657  *  @leave Leaves if not enough memory is available.
   655  *  
   658  *  
   656  */
   659  */
   657 void CSmsProtocol::AddSmsMessageObserverL(MSmsMessageObserver& aObserver)
   660 void CSmsProtocol::AddSmsMessageObserverL(MSmsMessageObserver& aObserver)
   658     {
   661     {
   659     OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_ADDSMSMESSAGEOBSERVERL_1, "CSmsProtocol::AddSmsMessageObserverL [aObserver=0x%08x]", &aObserver);
   662     LOGSMSPROT2("CSmsProtocol::AddSmsMessageObserverL [aObserver=0x%08x]", &aObserver);
   660     iSmsMessageObserverList.AppendL(&aObserver);
   663     iSmsMessageObserverList.AppendL(&aObserver);
   661     SetClosingDown(EFalse);
   664     SetClosingDown(EFalse);
   662     }
   665     }
   663 
   666 
   664 /**
   667 /**
   671  *  @return KErrNone on success, or KErrAlreadyExists if a duplicate exists.
   674  *  @return KErrNone on success, or KErrAlreadyExists if a duplicate exists.
   672  *  
   675  *  
   673  */
   676  */
   674 TInt CSmsProtocol::BindSmsMessageObserver(MSmsMessageObserver& aObserver,const TSmsAddr& aSmsAddr)
   677 TInt CSmsProtocol::BindSmsMessageObserver(MSmsMessageObserver& aObserver,const TSmsAddr& aSmsAddr)
   675 	{
   678 	{
   676 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_BINDSMSMESSAGEOBSERVER_1, "CSmsProtocol::BindSmsMessageObserver 0x%08x", &aObserver);
   679 	LOGSMSPROT2("CSmsProtocol::BindSmsMessageObserver 0x%08x", &aObserver);
   677 	__ASSERT_DEBUG(ObserverIsPresent(aObserver),SmspPanic(ESmspMessageObserverNotFound));
   680 	__ASSERT_DEBUG(ObserverIsPresent(aObserver),SmspPanic(ESmspMessageObserverNotFound));
   678 	TInt ret=KErrNone;
   681 	TInt ret=KErrNone;
   679 
   682 
   680 	if (!SmsAddrIsAlreadyUsed(&aObserver,aSmsAddr))
   683 	if (!SmsAddrIsAlreadyUsed(&aObserver,aSmsAddr))
   681 		{
   684 		{
   691 			// if there are any, send them to the observer
   694 			// if there are any, send them to the observer
   692 			//
   695 			//
   693 			TRAP(ret, ProcessCompleteSmsMessagesL());
   696 			TRAP(ret, ProcessCompleteSmsMessagesL());
   694 			if(ret != KErrNone)
   697 			if(ret != KErrNone)
   695 				{
   698 				{
   696 				OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_BINDSMSMESSAGEOBSERVER_2, "WARNING! CSmsProtocol::ProcessCompleteSmsMessagesL left with %d", ret);
   699 				LOGSMSPROT2("WARNING! CSmsProtocol::ProcessCompleteSmsMessagesL left with %d", ret);
   697 				}
   700 				}
   698 			}
   701 			}
   699 		}
   702 		}
   700 	else
   703 	else
   701 		{
   704 		{
   710  *  Observers should at least call this method in their destructors.
   713  *  Observers should at least call this method in their destructors.
   711  *  
   714  *  
   712  */
   715  */
   713 void CSmsProtocol::RemoveSmsMessageObserver(const MSmsMessageObserver& aObserver)
   716 void CSmsProtocol::RemoveSmsMessageObserver(const MSmsMessageObserver& aObserver)
   714     {
   717     {
   715     OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_REMOVESMSMESSAGEOBSERVER_1, "CSmsProtocol::RemoveSmsMessageObserver 0x%08x", &aObserver);
   718     LOGSMSPROT2("CSmsProtocol::RemoveSmsMessageObserver 0x%08x", &aObserver);
   716     __ASSERT_DEBUG(ObserverIsPresent(aObserver),SmspPanic(ESmspMessageObserverNotFound));
   719     __ASSERT_DEBUG(ObserverIsPresent(aObserver),SmspPanic(ESmspMessageObserverNotFound));
   717     TInt index=ObserverIndex(aObserver);
   720     TInt index=ObserverIndex(aObserver);
   718     iSmsMessageObserverList.Delete(index);
   721     iSmsMessageObserverList.Delete(index);
   719     }
   722     }
   720 
   723 
   723  *  Ensures there is a current connection to the modem and queues the message.
   726  *  Ensures there is a current connection to the modem and queues the message.
   724  *  Completes with an error immediately if CheckPoweredUp() returns an error code
   727  *  Completes with an error immediately if CheckPoweredUp() returns an error code
   725  */
   728  */
   726 void CSmsProtocol::SendSmsMessage(CSmsMessage* aSmsMessage,MSmsMessageObserver& aObserver,TUint aOptions)
   729 void CSmsProtocol::SendSmsMessage(CSmsMessage* aSmsMessage,MSmsMessageObserver& aObserver,TUint aOptions)
   727 	{
   730 	{
   728     OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_SENDSMSMESSAGE_1, "CSmsProtocol::SendSmsMessage [aObserver=0x%08X]", (TUint) &aObserver);
   731 	LOGSMSPROT2("CSmsProtocol::SendSmsMessage [aObserver=0x%X]", &aObserver);
   729 	__ASSERT_DEBUG(ObserverIsPresent(aObserver), SmspPanic(ESmspMessageObserverNotFound));
   732 	__ASSERT_DEBUG(ObserverIsPresent(aObserver), SmspPanic(ESmspMessageObserverNotFound));
   730 
   733 
   731 	// Ensure the modem is connected and initialized
   734 	// Ensure the modem is connected and initialized
   732 	const TInt err = CheckPoweredUp();
   735 	const TInt err = CheckPoweredUp();
   733 
   736 
   759         {
   762         {
   760         err = iSmsPhoneInitialization->Initialized();
   763         err = iSmsPhoneInitialization->Initialized();
   761         }
   764         }
   762     if( err != KErrNone )
   765     if( err != KErrNone )
   763         {
   766         {
   764         OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_CHECKPOWEREDUP_1, "CSmsProtocol::CheckPoweredUp [err=%d, iModemDetection=%d, IsBackupOrRestoreInProgress=%d]", err, iModemDetection, iBackupRestoreSession->IsBackupOrRestoreInProgress());
   767         LOGSMSPROT4("CSmsProtocol::CheckPoweredUp [err=%d, iModemDetection=%d, IsBackupOrRestoreInProgress=%d]", err, iModemDetection, iBackupRestoreSession->IsBackupOrRestoreInProgress());
   765         }    
   768         }    
   766     return err;
   769     return err;
   767     }
   770     }
   768 
   771 
   769 /**
   772 /**
   777  *  @leave Panics in DEBUG if the message is not found in the queue.
   780  *  @leave Panics in DEBUG if the message is not found in the queue.
   778  *  
   781  *  
   779  */
   782  */
   780 void CSmsProtocol::CancelSendSmsMessage(MSmsMessageObserver& aObserver,TBool)
   783 void CSmsProtocol::CancelSendSmsMessage(MSmsMessageObserver& aObserver,TBool)
   781 	{
   784 	{
   782 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_CANCELSENDSMSMESSAGE_1, "CSmsProtocol::CancelSendSmsMessage 0x%08x", &aObserver);
   785 	LOGSMSPROT2("CSmsProtocol::CancelSendSmsMessage 0x%08x", &aObserver);
   783 
   786 
   784 	__ASSERT_DEBUG(ObserverIsPresent(aObserver),SmspPanic(ESmspMessageObserverNotFound));
   787 	__ASSERT_DEBUG(ObserverIsPresent(aObserver),SmspPanic(ESmspMessageObserverNotFound));
   785 
   788 
   786 	iSendQueue->CancelObserver(aObserver);
   789 	iSendQueue->CancelObserver(aObserver);
   787 	} // CSmsProtocol::CancelSendSmsMessage
   790 	} // CSmsProtocol::CancelSendSmsMessage
   790 /**
   793 /**
   791  *  Handles a request from a SAP to enumerate the SMS messages stored on the phone.
   794  *  Handles a request from a SAP to enumerate the SMS messages stored on the phone.
   792  */
   795  */
   793 void CSmsProtocol::EnumeratePhone(MSmsMessageObserver& aObserver)
   796 void CSmsProtocol::EnumeratePhone(MSmsMessageObserver& aObserver)
   794 	{
   797 	{
   795 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_ENUMERATEPHONE_1, "CSmsProtocol::EnumeratePhone");
   798 	LOGSMSPROT1("CSmsProtocol::EnumeratePhone");
   796 	__ASSERT_DEBUG(ObserverIsPresent(aObserver),SmspPanic(ESmspMessageObserverNotFound));
   799 	__ASSERT_DEBUG(ObserverIsPresent(aObserver),SmspPanic(ESmspMessageObserverNotFound));
   797 
   800 
   798 	// Ensure the modem is connected and initialized
   801 	// Ensure the modem is connected and initialized
   799 	const TInt err = CheckPoweredUp();
   802 	const TInt err = CheckPoweredUp();
   800 
   803 
   821  *  @leave Panics in DEBUG if the SAP is invalid.
   824  *  @leave Panics in DEBUG if the SAP is invalid.
   822  *  
   825  *  
   823  */
   826  */
   824 void CSmsProtocol::CancelEnumeratePhone(MSmsMessageObserver& aObserver)
   827 void CSmsProtocol::CancelEnumeratePhone(MSmsMessageObserver& aObserver)
   825 	{
   828 	{
   826 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_CANCELENUMERATEPHONE_1, "CSmsProtocol::CancelEnumeratePhone");
   829 	LOGSMSPROT1("CSmsProtocol::CancelEnumeratePhone");
   827 
   830 
   828 	__ASSERT_DEBUG(ObserverIsPresent(aObserver), SmspPanic(ESmspMessageObserverNotFound));
   831 	__ASSERT_DEBUG(ObserverIsPresent(aObserver), SmspPanic(ESmspMessageObserverNotFound));
   829 	__ASSERT_DEBUG(iPhoneEnumerationObserver==NULL || &aObserver==iPhoneEnumerationObserver, SmspPanic(ESmspMessageWrongObserver));
   832 	__ASSERT_DEBUG(iPhoneEnumerationObserver==NULL || &aObserver==iPhoneEnumerationObserver, SmspPanic(ESmspMessageWrongObserver));
   830 
   833 
   831 	if (iSmsPhoneEnumeration != NULL)
   834 	if (iSmsPhoneEnumeration != NULL)
   850  *  Completes with an error immediately if CheckPoweredUp() returns an error code
   853  *  Completes with an error immediately if CheckPoweredUp() returns an error code
   851  *  Otherwise the message is added to the tail of the write queue.
   854  *  Otherwise the message is added to the tail of the write queue.
   852  */
   855  */
   853 void CSmsProtocol::WriteSmsMessage(CSmsMessage* aSmsMessage,MSmsMessageObserver& aObserver)
   856 void CSmsProtocol::WriteSmsMessage(CSmsMessage* aSmsMessage,MSmsMessageObserver& aObserver)
   854 	{
   857 	{
   855 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_WRITESMSMESSAGE_1, "CSmsProtocol::WriteSmsMessage");
   858 	LOGSMSPROT1("CSmsProtocol::WriteSmsMessage");
   856 	__ASSERT_DEBUG(ObserverIsPresent(aObserver),SmspPanic(ESmspMessageObserverNotFound));
   859 	__ASSERT_DEBUG(ObserverIsPresent(aObserver),SmspPanic(ESmspMessageObserverNotFound));
   857 
   860 
   858 	const TInt err = CheckPoweredUp();
   861 	const TInt err = CheckPoweredUp();
   859 
   862 
   860 	if (err != KErrNone)
   863 	if (err != KErrNone)
   869 	} // CSmsProtocol::WriteSmsMessage
   872 	} // CSmsProtocol::WriteSmsMessage
   870 
   873 
   871 
   874 
   872 void CSmsProtocol::CancelWriteSmsMessage(MSmsMessageObserver& aObserver)
   875 void CSmsProtocol::CancelWriteSmsMessage(MSmsMessageObserver& aObserver)
   873 	{
   876 	{
   874 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_CANCELWRITESMSMESSAGE_1, "CSmsProtocol::CancelWriteSmsMessage()");
   877 	LOGSMSPROT1("CSmsProtocol::CancelWriteSmsMessage()");
   875 
   878 
   876 	if (iWriteQueue != NULL)
   879 	if (iWriteQueue != NULL)
   877 		iWriteQueue->CancelObserver(aObserver);
   880 		iWriteQueue->CancelObserver(aObserver);
   878 	} // CSmsProtocol::CancelWriteSmsMessage
   881 	} // CSmsProtocol::CancelWriteSmsMessage
   879 
   882 
   888  *  @note aSmsMessage is destroyed from memory on completion.
   891  *  @note aSmsMessage is destroyed from memory on completion.
   889  *  
   892  *  
   890  */
   893  */
   891 void CSmsProtocol::DeleteSmsMessage(CSmsMessage* aSmsMessage,MSmsMessageObserver& aObserver)
   894 void CSmsProtocol::DeleteSmsMessage(CSmsMessage* aSmsMessage,MSmsMessageObserver& aObserver)
   892 	{
   895 	{
   893 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_DELETESMSMESSAGE_1, "CSmsProtocol::DeleteSmsMessage");
   896 	LOGSMSPROT1("CSmsProtocol::DeleteSmsMessage");
   894 	__ASSERT_DEBUG(ObserverIsPresent(aObserver),SmspPanic(ESmspMessageObserverNotFound));
   897 	__ASSERT_DEBUG(ObserverIsPresent(aObserver),SmspPanic(ESmspMessageObserverNotFound));
   895 
   898 
   896 	// Ensure the modem is connected and initialized
   899 	// Ensure the modem is connected and initialized
   897 	const TInt err = CheckPoweredUp();
   900 	const TInt err = CheckPoweredUp();
   898 
   901 
   916  *  @leave Panics in DEBUG if the SAP is invalid.
   919  *  @leave Panics in DEBUG if the SAP is invalid.
   917  *  
   920  *  
   918  */
   921  */
   919 void CSmsProtocol::CancelDeleteSmsMessage(MSmsMessageObserver& aObserver)
   922 void CSmsProtocol::CancelDeleteSmsMessage(MSmsMessageObserver& aObserver)
   920 	{
   923 	{
   921 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_CANCELDELETESMSMESSAGE_1, "CSmsProtocol::CancelDeleteSmsMessage");
   924 	LOGSMSPROT1("CSmsProtocol::CancelDeleteSmsMessage");
   922 
   925 
   923 	__ASSERT_DEBUG(ObserverIsPresent(aObserver),SmspPanic(ESmspMessageObserverNotFound));
   926 	__ASSERT_DEBUG(ObserverIsPresent(aObserver),SmspPanic(ESmspMessageObserverNotFound));
   924 
   927 
   925 	iDeleteQueue->CancelObserver(aObserver);
   928 	iDeleteQueue->CancelObserver(aObserver);
   926 	} // CSmsProtocol::CancelDeleteSmsMessage
   929 	} // CSmsProtocol::CancelDeleteSmsMessage
   937  *  Otherwise, the reading process is started.
   940  *  Otherwise, the reading process is started.
   938  *  
   941  *  
   939  */
   942  */
   940 void CSmsProtocol::ReadSmsParameters(MSmsMessageObserver& aObserver)
   943 void CSmsProtocol::ReadSmsParameters(MSmsMessageObserver& aObserver)
   941 	{
   944 	{
   942 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_READSMSPARAMETERS_1, "CSmsProtocol::ReadSmsParameters");
   945 	LOGSMSPROT1("CSmsProtocol::ReadSmsParameters");
   943 	__ASSERT_DEBUG(ObserverIsPresent(aObserver),SmspPanic(ESmspMessageObserverNotFound));
   946 	__ASSERT_DEBUG(ObserverIsPresent(aObserver),SmspPanic(ESmspMessageObserverNotFound));
   944 	TInt ret = CheckPoweredUp();
   947 	TInt ret = CheckPoweredUp();
   945 
   948 
   946 	if (ret == KErrNone)
   949 	if (ret == KErrNone)
   947 		{
   950 		{
   971  *  Cancels a previous request to read SMS parameters.
   974  *  Cancels a previous request to read SMS parameters.
   972  *  
   975  *  
   973  */
   976  */
   974 void CSmsProtocol::CancelReadSmsParams()
   977 void CSmsProtocol::CancelReadSmsParams()
   975 	{
   978 	{
   976 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_CANCELREADSMSPARAMS_1, "CSmsProtocol::CancelReadSmsParams");
   979 	LOGSMSPROT1("CSmsProtocol::CancelReadSmsParams");
   977 
   980 
   978 	if(iSmsReadParams != NULL)
   981 	if(iSmsReadParams != NULL)
   979 		iSmsReadParams->Cancel();
   982 		iSmsReadParams->Cancel();
   980 	} // CSmsProtocol::CancelReadSmsParams
   983 	} // CSmsProtocol::CancelReadSmsParams
   981 
   984 
   991  *  Otherwise, the writing process is started.
   994  *  Otherwise, the writing process is started.
   992  *  
   995  *  
   993  */
   996  */
   994 void CSmsProtocol::WriteSmsParameters(CMobilePhoneSmspList* aMobilePhoneSmspList,MSmsMessageObserver& aObserver)
   997 void CSmsProtocol::WriteSmsParameters(CMobilePhoneSmspList* aMobilePhoneSmspList,MSmsMessageObserver& aObserver)
   995 	{
   998 	{
   996 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_WRITESMSPARAMETERS_1, "CSmsProtocol::WriteSmsParameters");
   999 	LOGSMSPROT1("CSmsProtocol::WriteSmsParameters");
   997 	__ASSERT_DEBUG(ObserverIsPresent(aObserver),SmspPanic(ESmspMessageObserverNotFound));
  1000 	__ASSERT_DEBUG(ObserverIsPresent(aObserver),SmspPanic(ESmspMessageObserverNotFound));
   998 
  1001 
   999 	TInt ret = CheckPoweredUp();
  1002 	TInt ret = CheckPoweredUp();
  1000 
  1003 
  1001 	if (ret == KErrNone)
  1004 	if (ret == KErrNone)
  1037  *  Cancels a previous request to write SMS parameters.
  1040  *  Cancels a previous request to write SMS parameters.
  1038  *  
  1041  *  
  1039  */
  1042  */
  1040 void CSmsProtocol::CancelWriteSmsParams()
  1043 void CSmsProtocol::CancelWriteSmsParams()
  1041 	{
  1044 	{
  1042 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_CANCELWRITESMSPARAMS_1, "CSmsProtocol::CancelWriteSmsParams");
  1045 	LOGSMSPROT1("CSmsProtocol::CancelWriteSmsParams");
  1043 
  1046 
  1044 	if(iSmsWriteParams != NULL)
  1047 	if(iSmsWriteParams != NULL)
  1045 		iSmsWriteParams->Cancel();
  1048 		iSmsWriteParams->Cancel();
  1046 	} // CSmsProtocol::CancelWriteSmsParams
  1049 	} // CSmsProtocol::CancelWriteSmsParams
  1047 
  1050 
  1068  *  
  1071  *  
  1069  */
  1072  */
  1070 TInt CSmsProtocol::ProcessMessageL(const CSmsMessage& aSmsMessage,const TSmsAddr* aOriginalSmsAddr,
  1073 TInt CSmsProtocol::ProcessMessageL(const CSmsMessage& aSmsMessage,const TSmsAddr* aOriginalSmsAddr,
  1071 		const CSmsMessage* /*aOriginalSmsMessage*/,TDes& aDes)
  1074 		const CSmsMessage* /*aOriginalSmsMessage*/,TDes& aDes)
  1072 	{
  1075 	{
  1073 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_PROCESSMESSAGEL_1, "CSmsProtocol::ProcessMessage");
  1076 	LOGSMSPROT1("CSmsProtocol::ProcessMessage");
  1074 
  1077 
  1075 	MSmsMessageObserver* observer=NULL;
  1078 	MSmsMessageObserver* observer=NULL;
  1076 	if (aOriginalSmsAddr!=NULL)
  1079 	if (aOriginalSmsAddr!=NULL)
  1077 		{
  1080 		{
  1078 		// Status report and original message matched - send to original sender as priority
  1081 		// Status report and original message matched - send to original sender as priority
  1087 		{
  1090 		{
  1088 		// Only match if not currently enumerating or if it is meant for an app port.
  1091 		// Only match if not currently enumerating or if it is meant for an app port.
  1089 		observer = MatchSmsMessageToObserver(aSmsMessage);
  1092 		observer = MatchSmsMessageToObserver(aSmsMessage);
  1090 		}
  1093 		}
  1091 
  1094 
  1092 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_PROCESSMESSAGEL_2, "CSmsProtocol::ProcessMessage [observer=0x%08x]",observer);
  1095 	LOGSMSPROT2("CSmsProtocol::ProcessMessage [observer=0x%08x]",observer);
  1093 	TInt ret=KErrNone;
  1096 	TInt ret=KErrNone;
  1094 
  1097 
  1095 	if (observer!=NULL)
  1098 	if (observer!=NULL)
  1096 		{
  1099 		{
  1097 		TBool isAppPortSms = IsAppPortSMS(aSmsMessage );
  1100 		TBool isAppPortSms = IsAppPortSMS(aSmsMessage );
  1137  *  
  1140  *  
  1138  *  @param aSlotArray
  1141  *  @param aSlotArray
  1139  */
  1142  */
  1140 void CSmsProtocol::DeletePDUs(const CArrayFix<TGsmSmsSlotEntry>& aSlotArray, MSmsMessageObserver* aObserver)
  1143 void CSmsProtocol::DeletePDUs(const CArrayFix<TGsmSmsSlotEntry>& aSlotArray, MSmsMessageObserver* aObserver)
  1141 	{
  1144 	{
  1142     OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_DELETEPDUS_1, "CSmsProtocol::DeletePDUs [count=%d aObserver=0x%08X", aSlotArray.Count(), (TUint)aObserver);
  1145 	LOGSMSPROT3("CSmsProtocol::DeletePDUs [count=%d aObserver=0x%08X", aSlotArray.Count(), aObserver);
  1143     __ASSERT_DEBUG(aSlotArray.Count() != 0, SmspPanic(KSmspSlotArrayEmpty));
  1146 	__ASSERT_DEBUG(aSlotArray.Count() != 0, SmspPanic(KSmspSlotArrayEmpty));
  1144 
  1147 
  1145     for(TInt i=0; i< aSlotArray.Count() ;i++)
  1148 	for(TInt i=0; i< aSlotArray.Count() ;i++)
  1146         {
  1149 		{
  1147         OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_DELETEPDUS_2, "CSmsProtocol::DeletePDUs index: %d store %S", aSlotArray[i].iIndex, aSlotArray[i].iStore);
  1150 		LOGSMSPROT3("CSmsProtocol::DeletePDUs index: %d store %S", aSlotArray[i].iIndex, &aSlotArray[i].iStore);
  1148         }
  1151 		}
  1149 
  1152 
  1150 	if (iDeleteQueue != NULL && aSlotArray.Count() != 0)
  1153 	if (iDeleteQueue != NULL && aSlotArray.Count() != 0)
  1151 		{
  1154 		{
  1152 		iDeleteQueue->Queue(aSlotArray, aObserver);
  1155 		iDeleteQueue->Queue(aSlotArray, aObserver);
  1153 		}
  1156 		}
  1161  *  
  1164  *  
  1162  */
  1165  */
  1163 void CSmsProtocol::ModemNotificationCompleted(TInt aStatus,
  1166 void CSmsProtocol::ModemNotificationCompleted(TInt aStatus,
  1164 											  RPhone::TModemDetection aNewState)
  1167 											  RPhone::TModemDetection aNewState)
  1165 	{
  1168 	{
  1166 	OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_MODEMNOTIFICATIONCOMPLETED_1, "CSmsProtocol::ModemNotificationCompleted(): aStatus=%d, aNewState=%d",aStatus, aNewState);
  1169 	LOGSMSPROT3("CSmsProtocol::ModemNotificationCompleted(): aStatus=%d, aNewState=%d",
       
  1170 				aStatus, aNewState);
  1167 
  1171 
  1168 	TBool stateChanged = EFalse;
  1172 	TBool stateChanged = EFalse;
  1169 
  1173 
  1170 	if (aStatus==KErrNone)
  1174 	if (aStatus==KErrNone)
  1171 		{
  1175 		{
  1175 			// it goes from OFF to ON
  1179 			// it goes from OFF to ON
  1176 			//
  1180 			//
  1177 			case RPhone::EDetectedNotPresent:
  1181 			case RPhone::EDetectedNotPresent:
  1178 			case RPhone::EDetectedUnknown:
  1182 			case RPhone::EDetectedUnknown:
  1179 				{
  1183 				{
  1180 				OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_MODEMNOTIFICATIONCOMPLETED_2, "RPhone::EDetectedNotPresent: [OFF -> ON]");
  1184 				LOGSMSPROT1("RPhone::EDetectedNotPresent: [OFF -> ON]");
  1181 				if (aNewState==RPhone::EDetectedPresent)
  1185 				if (aNewState==RPhone::EDetectedPresent)
  1182 					{
  1186 					{
  1183 					// There is a new modem connection
  1187 					// There is a new modem connection
  1184 					iModemDetection=aNewState;
  1188 					iModemDetection=aNewState;
  1185 					stateChanged = ETrue;
  1189 					stateChanged = ETrue;
  1189 			//
  1193 			//
  1190 			// it goes from ON to OFF
  1194 			// it goes from ON to OFF
  1191 			//
  1195 			//
  1192 			case RPhone::EDetectedPresent:
  1196 			case RPhone::EDetectedPresent:
  1193 				{
  1197 				{
  1194 				OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_MODEMNOTIFICATIONCOMPLETED_3, "RPhone::EDetectedPresent: [ON -> OFF]");
  1198 				LOGSMSPROT1("RPhone::EDetectedPresent: [ON -> OFF]");
  1195 				if (aNewState!=RPhone::EDetectedPresent)
  1199 				if (aNewState!=RPhone::EDetectedPresent)
  1196 					{
  1200 					{
  1197 					// Ah, lost our modem - cancel outstanding operations
  1201 					// Ah, lost our modem - cancel outstanding operations
  1198 					iModemDetection=aNewState;
  1202 					iModemDetection=aNewState;
  1199 					stateChanged = ETrue;
  1203 					stateChanged = ETrue;
  1224 void CSmsProtocol::DiskSpaceMonitorStateChange(TSmsDiskSpaceMonitorStatus aStatus)
  1228 void CSmsProtocol::DiskSpaceMonitorStateChange(TSmsDiskSpaceMonitorStatus aStatus)
  1225 /**
  1229 /**
  1226  * Called when the Disk Space Monitor state has changed.
  1230  * Called when the Disk Space Monitor state has changed.
  1227  */
  1231  */
  1228 	{
  1232 	{
  1229 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_DISKSPACEMONITORSTATECHANGE_1, "CSmsProtocol::DiskSpaceMonitorStateChange(): aStatus=%d", aStatus);
  1233 	LOGSMSPROT2("CSmsProtocol::DiskSpaceMonitorStateChange(): aStatus=%d", aStatus);
  1230 
  1234 
  1231 	RProperty::Set(KUidPSSMSStackCategory, KUidPSSMSStackDiskSpaceMonitorKey, aStatus);
  1235 	RProperty::Set(KUidPSSMSStackCategory, KUidPSSMSStackDiskSpaceMonitorKey, aStatus);
  1232 	} // CSmsProtocol::DiskSpaceMonitorStateChange
  1236 	} // CSmsProtocol::DiskSpaceMonitorStateChange
  1233 
  1237 
  1234 
  1238 
  1237  *  Increments the number of segmentation store accesses and purges the store
  1241  *  Increments the number of segmentation store accesses and purges the store
  1238  *  if it exceeds CSmsProtocol::KNumSARStoreAccessesBeforePurging.
  1242  *  if it exceeds CSmsProtocol::KNumSARStoreAccessesBeforePurging.
  1239  */
  1243  */
  1240 void CSmsProtocol::MessageSendCompleted(TInt aStatus)
  1244 void CSmsProtocol::MessageSendCompleted(TInt aStatus)
  1241 	{
  1245 	{
  1242 	OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_MESSAGESENDCOMPLETED_1, "*** CSmsProtocol::MessageSendCompleted [aStatus=%d iNumSegmentationStoreAccesses=%d]", aStatus, iNumSegmentationStoreAccesses);
  1246 	LOGSMSPROT3("*** CSmsProtocol::MessageSendCompleted [aStatus=%d iNumSegmentationStoreAccesses=%d]", aStatus, iNumSegmentationStoreAccesses);
  1243     (void) aStatus;
  1247     (void) aStatus;
  1244 	iNumSegmentationStoreAccesses++;
  1248 	iNumSegmentationStoreAccesses++;
  1245 	if (iNumSegmentationStoreAccesses>=KNumSARStoreAccessesBeforePurging)
  1249 	if (iNumSegmentationStoreAccesses>=KNumSARStoreAccessesBeforePurging)
  1246 		{
  1250 		{
  1247 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_MESSAGESENDCOMPLETED_2, "iSegmentationStore->PurgeL Start");
  1251 		LOGSMSPROT1("iSegmentationStore->PurgeL Start");
  1248 		TRAPD(ret, iSegmentationStore->PurgeL(iSmsSettings.KSegmentationLifetimeMultiplier(),EFalse));
  1252 		TRAPD(ret, iSegmentationStore->PurgeL(iSmsSettings.KSegmentationLifetimeMultiplier(),EFalse));
  1249 		if(ret!=KErrNone)
  1253 		if(ret!=KErrNone)
  1250 			{
  1254 			{
  1251 			// we need to close the file because the function
  1255 			// we need to close the file because the function
  1252 			// left with the file opened
  1256 			// left with the file opened
  1253 			// iSegmentationStore->CloseFile();
  1257 			// iSegmentationStore->CloseFile();
  1254 			OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_MESSAGESENDCOMPLETED_3, "WARNING! iSegmentationStore->PurgeL left with %d", ret);
  1258 			LOGSMSPROT2("WARNING! iSegmentationStore->PurgeL left with %d", ret);
  1255 			}
  1259 			}
  1256 		iNumSegmentationStoreAccesses=0;
  1260 		iNumSegmentationStoreAccesses=0;
  1257 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_MESSAGESENDCOMPLETED_4, "iSegmentationStore->PurgeL End [ret=%d]", ret);
  1261 		LOGSMSPROT2("iSegmentationStore->PurgeL End [ret=%d]", ret);
  1258 		}
  1262 		}
  1259 	} // CSmsProtocol::KNumSARStoreAccessesBeforePurging
  1263 	} // CSmsProtocol::KNumSARStoreAccessesBeforePurging
  1260 
  1264 
  1261 
  1265 
  1262 /**
  1266 /**
  1264  *  phone has completed.  Notifies the SAP that made the request.
  1268  *  phone has completed.  Notifies the SAP that made the request.
  1265  *  
  1269  *  
  1266  */
  1270  */
  1267 void CSmsProtocol::PhoneEnumerationCompleted(TInt aStatus)
  1271 void CSmsProtocol::PhoneEnumerationCompleted(TInt aStatus)
  1268 	{
  1272 	{
  1269 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_PHONEENUMERATIONCOMPLETED_1, "CSmsProtocol::PhoneEnumerationCompleted");
  1273 	LOGSMSPROT1("CSmsProtocol::PhoneEnumerationCompleted");
  1270 	iPhoneEnumerationObserver->EnumeratePhoneCompleted(aStatus);
  1274 	iPhoneEnumerationObserver->EnumeratePhoneCompleted(aStatus);
  1271 	} // CSmsProtocol::PhoneEnumerationCompleted
  1275 	} // CSmsProtocol::PhoneEnumerationCompleted
  1272 
  1276 
  1273 
  1277 
  1274 /**
  1278 /**
  1277  *  is set, otherwise CProtocolBase::CanClose() is called to finish closing.
  1281  *  is set, otherwise CProtocolBase::CanClose() is called to finish closing.
  1278  *  
  1282  *  
  1279  */
  1283  */
  1280 void CSmsProtocol::CloseNow()
  1284 void CSmsProtocol::CloseNow()
  1281 	{
  1285 	{
  1282 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_CLOSENOW_1, "CSmsProtocol::CloseNow");
  1286 	LOGSMSPROT1("CSmsProtocol::CloseNow");
  1283 	if (iDeleteQueue != NULL && iDeleteQueue->IsActive())
  1287 	if (iDeleteQueue != NULL && iDeleteQueue->IsActive())
  1284 		SetClosingDown(ETrue);
  1288 		SetClosingDown(ETrue);
  1285 	else
  1289 	else
  1286 		CanClose();
  1290 		CanClose();
  1287 	} // CSmsProtocol::CloseNow
  1291 	} // CSmsProtocol::CloseNow
  1307  *  Returns the index of an observer in the observer list.
  1311  *  Returns the index of an observer in the observer list.
  1308  *  
  1312  *  
  1309  */
  1313  */
  1310 TInt CSmsProtocol::ObserverIndex(const MSmsMessageObserver& aObserver) const
  1314 TInt CSmsProtocol::ObserverIndex(const MSmsMessageObserver& aObserver) const
  1311 	{
  1315 	{
  1312 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_OBSERVERINDEX_1, "CSmsProtocol::ObserverIndex()");
  1316 	LOGSMSPROT1("CSmsProtocol::ObserverIndex()");
  1313 
  1317 
  1314 	TInt count=iSmsMessageObserverList.Count();
  1318 	TInt count=iSmsMessageObserverList.Count();
  1315 	TInt index=0;
  1319 	TInt index=0;
  1316 	for (; index<count; index++)
  1320 	for (; index<count; index++)
  1317 		if (iSmsMessageObserverList[index]==&aObserver)
  1321 		if (iSmsMessageObserverList[index]==&aObserver)
  1324  *  Checks if an SMS address type is a duplicate of an existing SAP / observer.
  1328  *  Checks if an SMS address type is a duplicate of an existing SAP / observer.
  1325  *  
  1329  *  
  1326  */
  1330  */
  1327 TBool CSmsProtocol::SmsAddrIsAlreadyUsed(const MSmsMessageObserver* aObserver,const TSmsAddr& aSmsAddr)const
  1331 TBool CSmsProtocol::SmsAddrIsAlreadyUsed(const MSmsMessageObserver* aObserver,const TSmsAddr& aSmsAddr)const
  1328 	{
  1332 	{
  1329 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_SMSADDRISALREADYUSED_1, "CSmsProtocol::SmsAddrIsAlreadyUsed()");
  1333 	LOGSMSPROT1("CSmsProtocol::SmsAddrIsAlreadyUsed()");
  1330 
  1334 
  1331 	TBool isduplicate=EFalse;
  1335 	TBool isduplicate=EFalse;
  1332 	TInt count=iSmsMessageObserverList.Count();
  1336 	TInt count=iSmsMessageObserverList.Count();
  1333 	for (TInt i=0; (i<count) && (!isduplicate); i++)
  1337 	for (TInt i=0; (i<count) && (!isduplicate); i++)
  1334 		isduplicate=(iSmsMessageObserverList[i]->SmsAddrIsDuplicate(aObserver,aSmsAddr));
  1338 		isduplicate=(iSmsMessageObserverList[i]->SmsAddrIsDuplicate(aObserver,aSmsAddr));
  1409  *  the observer list based on their address types.
  1413  *  the observer list based on their address types.
  1410  *  
  1414  *  
  1411  */
  1415  */
  1412 TInt TKeySmsObserver::Compare(TInt aLeft, TInt aRight) const
  1416 TInt TKeySmsObserver::Compare(TInt aLeft, TInt aRight) const
  1413 	{
  1417 	{
  1414 	OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, TKEYSMSOBSERVER_COMPARE_1, "TKeySmsObserver::Compare [left=%d, right=%d]", aLeft, aRight);
  1418 	LOGSMSPROT3("TKeySmsObserver::Compare [left=%d, right=%d]", aLeft, aRight);
  1415 
  1419 
  1416 	const TInt lhptr = -1; // Left higher priority than right
  1420 	const TInt lhptr = -1; // Left higher priority than right
  1417 	const TInt rhptl = 1; // Right higher priority than left
  1421 	const TInt rhptl = 1; // Right higher priority than left
  1418 
  1422 
  1419 	MSmsMessageObserver* left = *(MSmsMessageObserver**)At(aLeft);
  1423 	MSmsMessageObserver* left = *(MSmsMessageObserver**)At(aLeft);
  1452  *  Re-orders the observer list using TKeySmsObserver to determine priorities.
  1456  *  Re-orders the observer list using TKeySmsObserver to determine priorities.
  1453  *  
  1457  *  
  1454  */
  1458  */
  1455 void CSmsProtocol::OrderSmsMessageObserver(const MSmsMessageObserver& /*aObserver*/)
  1459 void CSmsProtocol::OrderSmsMessageObserver(const MSmsMessageObserver& /*aObserver*/)
  1456 	{
  1460 	{
  1457 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_ORDERSMSMESSAGEOBSERVER_1, "CSmsProtocol::OrderSmsMessageObserver()");
  1461 	LOGSMSPROT1("CSmsProtocol::OrderSmsMessageObserver()");
  1458 
  1462 
  1459 	TKeySmsObserver smsObsKey;
  1463 	TKeySmsObserver smsObsKey;
  1460 #ifdef _DEBUG
  1464 #ifdef _DEBUG
  1461 	TInt ret=iSmsMessageObserverList.Sort(smsObsKey);
  1465 	TInt ret=iSmsMessageObserverList.Sort(smsObsKey);
  1462 	__ASSERT_DEBUG(ret==KErrNone,SmspPanic(ESmspCorruptObserverList));
  1466 	__ASSERT_DEBUG(ret==KErrNone,SmspPanic(ESmspCorruptObserverList));
  1471  *  highest priority observer.
  1475  *  highest priority observer.
  1472  *  
  1476  *  
  1473  */
  1477  */
  1474 MSmsMessageObserver* CSmsProtocol::MatchSmsMessageToObserver(const CSmsMessage& aSmsMessage)
  1478 MSmsMessageObserver* CSmsProtocol::MatchSmsMessageToObserver(const CSmsMessage& aSmsMessage)
  1475 	{
  1479 	{
  1476 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_MATCHSMSMESSAGETOOBSERVER_1, "CSmsProtocol::MatchSmsMessageToObserver()");
  1480 	LOGSMSPROT1("CSmsProtocol::MatchSmsMessageToObserver()");
  1477 
  1481 
  1478 	TInt count=iSmsMessageObserverList.Count();
  1482 	TInt count=iSmsMessageObserverList.Count();
  1479 	for (TInt i=0;i<count;i++)
  1483 	for (TInt i=0;i<count;i++)
  1480 		{
  1484 		{
  1481 		MSmsMessageObserver* obs = iSmsMessageObserverList[i];
  1485 		MSmsMessageObserver* obs = iSmsMessageObserverList[i];
  1491  *  priority observer.
  1495  *  priority observer.
  1492  *  
  1496  *  
  1493  */
  1497  */
  1494 MSmsMessageObserver* CSmsProtocol::MatchSmsAddressToObserver(const TSmsAddr& aAddr)
  1498 MSmsMessageObserver* CSmsProtocol::MatchSmsAddressToObserver(const TSmsAddr& aAddr)
  1495 	{
  1499 	{
  1496 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_MATCHSMSADDRESSTOOBSERVER_1, "CSmsProtocol::MatchSmsAddressToObserver()");
  1500 	LOGSMSPROT1("CSmsProtocol::MatchSmsAddressToObserver()");
  1497 
  1501 
  1498 	TInt count=iSmsMessageObserverList.Count();
  1502 	TInt count=iSmsMessageObserverList.Count();
  1499 	for (TInt i=0;i<count;i++)
  1503 	for (TInt i=0;i<count;i++)
  1500 		{
  1504 		{
  1501 		MSmsMessageObserver* obs = iSmsMessageObserverList[i];
  1505 		MSmsMessageObserver* obs = iSmsMessageObserverList[i];
  1511  *  MatchSmsMessageToObserver() to find a matching observer for the message.
  1515  *  MatchSmsMessageToObserver() to find a matching observer for the message.
  1512  *  
  1516  *  
  1513  */
  1517  */
  1514 TBool CSmsProtocol::IsMatch(const TSmsAddr& aSmsAddr, const CSmsMessage& aSmsMessage)
  1518 TBool CSmsProtocol::IsMatch(const TSmsAddr& aSmsAddr, const CSmsMessage& aSmsMessage)
  1515 	{
  1519 	{
  1516 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_ISMATCH_1, "CSmsProtocol::IsMatch()");
  1520 	LOGSMSPROT1("CSmsProtocol::IsMatch()");
  1517 
  1521 
  1518 	TSmsAddrFamily family = aSmsAddr.SmsAddrFamily();
  1522 	TSmsAddrFamily family = aSmsAddr.SmsAddrFamily();
  1519 
  1523 
  1520 	switch(family)
  1524 	switch(family)
  1521 	{
  1525 	{
  1567 			return EFalse;
  1571 			return EFalse;
  1568 			}
  1572 			}
  1569 
  1573 
  1570 		case (ESmsAddrStatusReport):
  1574 		case (ESmsAddrStatusReport):
  1571 			{
  1575 			{
  1572 			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_ISMATCH_2, "TSmsDataCodingScheme::ESmsDCSMessageWaitingIndicationDiscardMessage:");
  1576 			LOGSMSPROT1("TSmsDataCodingScheme::ESmsDCSMessageWaitingIndicationDiscardMessage:");
  1573 			if (aSmsMessage.Type() == CSmsPDU::ESmsStatusReport)
  1577 			if (aSmsMessage.Type() == CSmsPDU::ESmsStatusReport)
  1574 				return ETrue;
  1578 				return ETrue;
  1575 			}
  1579 			}
  1576 			break;
  1580 			break;
  1577 		case (ESmsAddrMatchIEI):
  1581 		case (ESmsAddrMatchIEI):
  1610  *  to determine if an SMS address type matches an application port.
  1614  *  to determine if an SMS address type matches an application port.
  1611  *  
  1615  *  
  1612  */
  1616  */
  1613 TBool CSmsProtocol::MatchApplicationPort(const CSmsMessage& aSmsMessage,TUint aPort,TBool a16Bit)
  1617 TBool CSmsProtocol::MatchApplicationPort(const CSmsMessage& aSmsMessage,TUint aPort,TBool a16Bit)
  1614 	{
  1618 	{
  1615 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_MATCHAPPLICATIONPORT_1, "CSmsProtocol::MatchApplicationPort");
  1619 	LOGSMSPROT1("CSmsProtocol::MatchApplicationPort");
  1616 
  1620 
  1617 	if (!aSmsMessage.SmsPDU().UserDataPresent())
  1621 	if (!aSmsMessage.SmsPDU().UserDataPresent())
  1618 		return EFalse;
  1622 		return EFalse;
  1619 
  1623 
  1620 	const CSmsPDU& Pdu = aSmsMessage.SmsPDU();
  1624 	const CSmsPDU& Pdu = aSmsMessage.SmsPDU();
  1634  *  to determine if an SMS address type matches a message.
  1638  *  to determine if an SMS address type matches a message.
  1635  *  
  1639  *  
  1636  */
  1640  */
  1637 TBool CSmsProtocol::MatchInformationElement(const CSmsMessage& aSmsMessage, CSmsInformationElement::TSmsInformationElementIdentifier aIeVal)
  1641 TBool CSmsProtocol::MatchInformationElement(const CSmsMessage& aSmsMessage, CSmsInformationElement::TSmsInformationElementIdentifier aIeVal)
  1638 	{
  1642 	{
  1639 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_MATCHINFORMATIONELEMENT_1, "CSmsProtocol::MatchInformationElement");
  1643 	LOGSMSPROT1("CSmsProtocol::MatchInformationElement");
  1640 
  1644 
  1641 	if (!aSmsMessage.SmsPDU().UserDataPresent())
  1645 	if (!aSmsMessage.SmsPDU().UserDataPresent())
  1642 		return EFalse;
  1646 		return EFalse;
  1643 
  1647 
  1644 	TInt count=aSmsMessage.SmsPDU().UserData().NumInformationElements();
  1648 	TInt count=aSmsMessage.SmsPDU().UserData().NumInformationElements();
  1660  *  successfully processed.
  1664  *  successfully processed.
  1661  *  
  1665  *  
  1662  */
  1666  */
  1663 void CSmsProtocol::ProcessCompleteSmsMessagesL()
  1667 void CSmsProtocol::ProcessCompleteSmsMessagesL()
  1664 	{
  1668 	{
  1665 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_PROCESSCOMPLETESMSMESSAGESL_1, "CSmsProtocol::ProcessCompleteSmsMessagesL");
  1669 	LOGSMSPROT1("CSmsProtocol::ProcessCompleteSmsMessagesL");
  1666 
  1670 
  1667 	if(iPhoneEnumerationObserver) return;
  1671 	if(iPhoneEnumerationObserver) return;
  1668 
  1672 
  1669 	iReassemblyStore->ProcessCompleteSmsMessagesL(*this, iSmsPDURead->CurrentMessage());
  1673 	iReassemblyStore->ProcessCompleteSmsMessagesL(*this, iSmsPDURead->CurrentMessage());
  1670 	} // CSmsProtocol::ProcessCompleteSmsMessagesL
  1674 	} // CSmsProtocol::ProcessCompleteSmsMessagesL
  1678  *  not empty, and the processing state machinery is started for the next entry.
  1682  *  not empty, and the processing state machinery is started for the next entry.
  1679  *  
  1683  *  
  1680  */
  1684  */
  1681 void CSmsProtocol::MessageReadedSuccessfully()
  1685 void CSmsProtocol::MessageReadedSuccessfully()
  1682 	{
  1686 	{
  1683 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_MESSAGEREADEDSUCCESSFULLY_1, "CSmsProtocol::MessageReadedSuccessfully");
  1687 	LOGSMSPROT1("CSmsProtocol::MessageReadedSuccessfully");
  1684 	TRAPD(ret,ProcessCompleteSmsMessagesL());
  1688 	TRAPD(ret,ProcessCompleteSmsMessagesL());
  1685 	if(ret!=KErrNone)
  1689 	if(ret!=KErrNone)
  1686 		{
  1690 		{
  1687 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_MESSAGEREADEDSUCCESSFULLY_2, "WARNING! CSmsProtocol::ProcessCompleteSmsMessagesL left with %d", ret);
  1691 		LOGSMSPROT2("WARNING! CSmsProtocol::ProcessCompleteSmsMessagesL left with %d", ret);
  1688 		}
  1692 		}
  1689 
  1693 
  1690 	iNumReassemblyStoreAccesses++;
  1694 	iNumReassemblyStoreAccesses++;
  1691 	if(iNumReassemblyStoreAccesses>=KNumSARStoreAccessesBeforePurging)
  1695 	if(iNumReassemblyStoreAccesses>=KNumSARStoreAccessesBeforePurging)
  1692 		{
  1696 		{
  1693 		TRAP(ret, iReassemblyStore->PurgeL(iSmsSettings.ReassemblyLifetime(),EFalse));
  1697 		TRAP(ret, iReassemblyStore->PurgeL(iSmsSettings.ReassemblyLifetime(),EFalse));
  1694 
  1698 
  1695 		if(ret!=KErrNone)
  1699 		if(ret!=KErrNone)
  1696 			{
  1700 			{
  1697 			OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_MESSAGEREADEDSUCCESSFULLY_3, "WARNING! iReassemblyStore->PurgeL left with %d", ret);
  1701 			LOGSMSPROT2("WARNING! iReassemblyStore->PurgeL left with %d", ret);
  1698 			}
  1702 			}
  1699 
  1703 
  1700 		iNumReassemblyStoreAccesses=0;
  1704 		iNumReassemblyStoreAccesses=0;
  1701 		}
  1705 		}
  1702 	if(CheckPoweredUp() == KErrNone )
  1706 	if(CheckPoweredUp() == KErrNone )
  1707 /**
  1711 /**
  1708  *  method to delete sms from the reastore
  1712  *  method to delete sms from the reastore
  1709  */
  1713  */
  1710 void CSmsProtocol::DeleteSMSFromReaStoreL(const CSmsMessage& aSmsMessage)
  1714 void CSmsProtocol::DeleteSMSFromReaStoreL(const CSmsMessage& aSmsMessage)
  1711 	{
  1715 	{
  1712 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_DELETESMSFROMREASTOREL_1, "CSmsProtocol::DeleteSMSFromReaStoreL entry");
  1716 	LOGSMSPROT1("CSmsProtocol::DeleteSMSFromReaStoreL entry");
  1713 	if (aSmsMessage.Type() == CSmsPDU::ESmsStatusReport)
  1717 	if (aSmsMessage.Type() == CSmsPDU::ESmsStatusReport)
  1714 	{
  1718 	{
  1715 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_DELETESMSFROMREASTOREL_2, "CSmsProtocol::DeleteSMSFromReaStoreL it's SR");
  1719 		LOGSMSPROT1("CSmsProtocol::DeleteSMSFromReaStoreL it's SR");
  1716 		return;
  1720 		return;
  1717 	}
  1721 	}
  1718 
  1722 
  1719 	TSmsDataCodingScheme::TSmsClass  msgClass;
  1723 	TSmsDataCodingScheme::TSmsClass  msgClass;
  1720 
  1724 
  1733 					{
  1737 					{
  1734 					/*
  1738 					/*
  1735 					Only in this condition set incomplete message as forwarded
  1739 					Only in this condition set incomplete message as forwarded
  1736 					which internally will remove the PDUs from pre-allocated file.
  1740 					which internally will remove the PDUs from pre-allocated file.
  1737 					*/
  1741 					*/
  1738 					OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_DELETESMSFROMREASTOREL_3, "CSmsProtocol::DeleteSMSFromReaStoreL Incomplete Message Not last segment");
  1742 					LOGSMSPROT1("CSmsProtocol::DeleteSMSFromReaStoreL Incomplete Message Not last segment");
  1739 					iReassemblyStore->SetIncompleteMessageForwardedToClientL(aSmsMessage);
  1743 					iReassemblyStore->SetIncompleteMessageForwardedToClientL(aSmsMessage);
  1740 					return;
  1744 					return;
  1741 					}
  1745 					}
  1742 				}
  1746 				}
  1743 			}
  1747 			}
  1744 		}
  1748 		}
  1745 	iReassemblyStore->DeleteMessageL(aSmsMessage, ETrue);
  1749 	iReassemblyStore->DeleteMessageL(aSmsMessage, ETrue);
  1746 
  1750 
  1747 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_DELETESMSFROMREASTOREL_4, "CSmsProtocol::DeleteSMSFromReaStoreL exit");
  1751 	LOGSMSPROT1("CSmsProtocol::DeleteSMSFromReaStoreL exit");
  1748 	} // CSmsProtocol::DeleteSMSFromReaStoreL
  1752 	} // CSmsProtocol::DeleteSMSFromReaStoreL
  1749 
  1753 
  1750 
  1754 
  1751 /**
  1755 /**
  1752  *  Used to notify observer of the change in state of the modem connection.
  1756  *  Used to notify observer of the change in state of the modem connection.
  1753  *  Send only observers are not notified (why?).
  1757  *  Send only observers are not notified (why?).
  1754  */
  1758  */
  1755 void CSmsProtocol::NotifyMessageObservers(TInt aStatus)
  1759 void CSmsProtocol::NotifyMessageObservers(TInt aStatus)
  1756 	{
  1760 	{
  1757 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_NOTIFYMESSAGEOBSERVERS_1, "CSmsProtocol::NotifyMessageObservers");
  1761 	LOGSMSPROT1("CSmsProtocol::NotifyMessageObservers");
  1758 
  1762 
  1759 	TInt count=iSmsMessageObserverList.Count();
  1763 	TInt count=iSmsMessageObserverList.Count();
  1760 	OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_NOTIFYMESSAGEOBSERVERS_2, "CSmsProtocol::NotifyMessageObservers [count=%d, aStatus=%d]",count, aStatus);
  1764 	LOGSMSPROT3("CSmsProtocol::NotifyMessageObservers [count=%d, aStatus=%d]",count, aStatus);
  1761 	for (TInt index=0; index<count; index++)
  1765 	for (TInt index=0; index<count; index++)
  1762 		{
  1766 		{
  1763 		MSmsMessageObserver* observer=iSmsMessageObserverList[index];
  1767 		MSmsMessageObserver* observer=iSmsMessageObserverList[index];
  1764 		TSmsAddrFamily fam = observer->GetLocalAddress().SmsAddrFamily();
  1768 		TSmsAddrFamily fam = observer->GetLocalAddress().SmsAddrFamily();
  1765 	    OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_NOTIFYMESSAGEOBSERVERS_3, "CSmsProtocol::NotifyMessageObservers [family=%d]", fam);
  1769 	    LOGSMSPROT2("CSmsProtocol::NotifyMessageObservers [family=%d]", fam);
  1766 		switch (fam)
  1770 		switch (fam)
  1767 			{
  1771 			{
  1768 			case ESmsAddrMessageIndication:
  1772 			case ESmsAddrMessageIndication:
  1769 			case ESmsAddrStatusReport:
  1773 			case ESmsAddrStatusReport:
  1770 			case ESmsAddrMatchIEI:
  1774 			case ESmsAddrMatchIEI:
  1788 	} // CSmsProtocol::NotifyMessageObservers
  1792 	} // CSmsProtocol::NotifyMessageObservers
  1789 
  1793 
  1790 
  1794 
  1791 void CSmsProtocol::PowerUp()
  1795 void CSmsProtocol::PowerUp()
  1792 	{
  1796 	{
  1793 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_POWERUP_1, "CSmsProtocol::PowerUp [iState=%d]", iState);
  1797 	LOGSMSPROT2("CSmsProtocol::PowerUp [iState=%d]", iState);
  1794 	__ASSERT_DEBUG(iState == EPoweredDown, SmspPanic(KSmspPanicUnexpectedState));
  1798 	__ASSERT_DEBUG(iState == EPoweredDown, SmspPanic(KSmspPanicUnexpectedState));
  1795 
  1799 
  1796 	if (iState == EPoweredDown)
  1800 	if (iState == EPoweredDown)
  1797 		{
  1801 		{
  1798 		TRAPD(err, DoPowerUpL());
  1802 		TRAPD(err, DoPowerUpL());
  1799 
  1803 
  1800 		if (err != KErrNone)
  1804 		if (err != KErrNone)
  1801 			{
  1805 			{
  1802 			OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_POWERUP_2, "WARNING: CSmsProtocol::DoPowerUpL left [err=%d iState=%d]", err, iState);
  1806 			LOGSMSPROT3("WARNING: CSmsProtocol::DoPowerUpL left [err=%d iState=%d]", err, iState);
  1803 			__ASSERT_DEBUG(iState == EPoweredDown, SmspPanic(KSmspPanicUnexpectedState));
  1807 			__ASSERT_DEBUG(iState == EPoweredDown, SmspPanic(KSmspPanicUnexpectedState));
  1804 			PowerDown();
  1808 			PowerDown();
  1805 			}
  1809 			}
  1806 		}
  1810 		}
  1807 	} // CSmsProtocol::PowerUp
  1811 	} // CSmsProtocol::PowerUp
  1816  *  - A number of state machines started
  1820  *  - A number of state machines started
  1817  *  
  1821  *  
  1818  */
  1822  */
  1819 void CSmsProtocol::DoPowerUpL()
  1823 void CSmsProtocol::DoPowerUpL()
  1820 	{
  1824 	{
  1821 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_DOPOWERUPL_1, "CSmsProtocol::DoPowerUpL");
  1825 	LOGSMSPROT1("CSmsProtocol::DoPowerUpL");
  1822 	__ASSERT_DEBUG(iModemDetection==RPhone::EDetectedPresent,SmspPanic(KSmspPhoneHasNotTurnedOn));
  1826 	__ASSERT_DEBUG(iModemDetection==RPhone::EDetectedPresent,SmspPanic(KSmspPhoneHasNotTurnedOn));
  1823 
  1827 
  1824 	//Open the segmentation and reassembly stores
  1828 	//Open the segmentation and reassembly stores
  1825 
  1829 
  1826 	iReassemblyStore->OpenStoreL();
  1830 	iReassemblyStore->OpenStoreL();
  1827 	iSegmentationStore->OpenStoreL();
  1831 	iSegmentationStore->OpenStoreL();
  1828 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_DOPOWERUPL_2, "CSmsProtocol::DoPowerUpL->PurgeL Start");
  1832 	LOGSMSPROT1("CSmsProtocol::DoPowerUpL->PurgeL Start");
  1829 	iReassemblyStore->PurgeL(iSmsSettings.ReassemblyLifetime(), ETrue);
  1833 	iReassemblyStore->PurgeL(iSmsSettings.ReassemblyLifetime(), ETrue);
  1830 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_DOPOWERUPL_3, "CSmsProtocol::DoPowerUpL->PurgeL End");
  1834 	LOGSMSPROT1("CSmsProtocol::DoPowerUpL->PurgeL End");
  1831 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_DOPOWERUPL_4, "CSmsProtocol::DoPowerUpL->PurgeL Start");
  1835 	LOGSMSPROT1("CSmsProtocol::DoPowerUpL->PurgeL Start");
  1832 	iSegmentationStore->PurgeL(iSmsSettings.KSegmentationLifetimeMultiplier(),EFalse);
  1836 	iSegmentationStore->PurgeL(iSmsSettings.KSegmentationLifetimeMultiplier(),EFalse);
  1833 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_DOPOWERUPL_5, "CSmsProtocol::DoPowerUpL->PurgeL End");
  1837 	LOGSMSPROT1("CSmsProtocol::DoPowerUpL->PurgeL End");
  1834 
  1838 
  1835 	// Connect to ETEL and load the TSY
  1839 	// Connect to ETEL and load the TSY
  1836 	User::LeaveIfError(iTelServer.Connect());
  1840 	User::LeaveIfError(iTelServer.Connect());
  1837 	User::LeaveIfError(iTelServer.LoadPhoneModule(iGsmTsyName));
  1841 	User::LeaveIfError(iTelServer.LoadPhoneModule(iGsmTsyName));
  1838 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_DOPOWERUPL_6, "CSmsProtocol::DoPowerUpL  Connected to Etel");
  1842 	LOGSMSPROT1("CSmsProtocol::DoPowerUpL  Connected to Etel");
  1839 
  1843 
  1840 	// Find the phone corresponding to this TSY and open a number of handles on it
  1844 	// Find the phone corresponding to this TSY and open a number of handles on it
  1841 	TInt numPhones;
  1845 	TInt numPhones;
  1842 	User::LeaveIfError(iTelServer.EnumeratePhones(numPhones));
  1846 	User::LeaveIfError(iTelServer.EnumeratePhones(numPhones));
  1843 	TInt i=0;
  1847 	TInt i=0;
  1858 	__ASSERT_DEBUG(i<numPhones,SmspPanic(ESmspPhoneNotFound));
  1862 	__ASSERT_DEBUG(i<numPhones,SmspPanic(ESmspPhoneNotFound));
  1859 	if (iTelServer.SetExtendedErrorGranularity(RTelServer::EErrorExtended)!=KErrNone)
  1863 	if (iTelServer.SetExtendedErrorGranularity(RTelServer::EErrorExtended)!=KErrNone)
  1860 		User::LeaveIfError(iTelServer.SetExtendedErrorGranularity(RTelServer::EErrorBasic));
  1864 		User::LeaveIfError(iTelServer.SetExtendedErrorGranularity(RTelServer::EErrorBasic));
  1861 	User::LeaveIfError(iSmsMessaging.Open(iGsmPhone));
  1865 	User::LeaveIfError(iSmsMessaging.Open(iGsmPhone));
  1862 
  1866 
  1863 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_DOPOWERUPL_7, "CSmsProtocol::DoPowerUpL  Opened TSY handles");
  1867 	LOGSMSPROT1("CSmsProtocol::DoPowerUpL  Opened TSY handles");
  1864 
  1868 
  1865 	if (iSmsPhoneEnumeration == NULL)
  1869 	if (iSmsPhoneEnumeration == NULL)
  1866 		iSmsPhoneEnumeration=CSmsPhoneEnumeration::NewL(*this, iSmsSettings, *iReassemblyStore, *iSegmentationStore, iEnumerationPhone, KSmsSessionPriority, *iSmsMonitorDiskSpace);
  1870 		iSmsPhoneEnumeration=CSmsPhoneEnumeration::NewL(*this, iSmsSettings, *iReassemblyStore, *iSegmentationStore, iEnumerationPhone, KSmsSessionPriority, *iSmsMonitorDiskSpace);
  1867 
  1871 
  1868 	if (iWriteQueue == NULL)
  1872 	if (iWriteQueue == NULL)
  1872 		iDeleteQueue = CSmspDeleteQueue::NewL(*this,iSmsSettings,iSmsMessaging, KSmsSessionPriority);
  1876 		iDeleteQueue = CSmspDeleteQueue::NewL(*this,iSmsSettings,iSmsMessaging, KSmsSessionPriority);
  1873 
  1877 
  1874 	// Start state machines
  1878 	// Start state machines
  1875 	iSmsPhoneInitialization->Start();
  1879 	iSmsPhoneInitialization->Start();
  1876 
  1880 
  1877 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_DOPOWERUPL_8, "CSmsProtocol::DoPowerUpL  Started state machines");
  1881 	LOGSMSPROT1("CSmsProtocol::DoPowerUpL  Started state machines");
  1878 
  1882 
  1879 	NotifyMessageObservers(KIoctlSelectModemPresent);
  1883 	NotifyMessageObservers(KIoctlSelectModemPresent);
  1880 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_DOPOWERUPL_9, "CSmsProtocol::DoPowerUpL  Notified message observers");
  1884 	LOGSMSPROT1("CSmsProtocol::DoPowerUpL  Notified message observers");
  1881 
  1885 
  1882 
  1886 
  1883 	// Process any waiting messages
  1887 	// Process any waiting messages
  1884 	ProcessCompleteSmsMessagesL();
  1888 	ProcessCompleteSmsMessagesL();
  1885 
  1889 
  1896  *  
  1900  *  
  1897  *  This function will also be called if PowerUpL() leaves
  1901  *  This function will also be called if PowerUpL() leaves
  1898  */
  1902  */
  1899 void CSmsProtocol::PowerDown()
  1903 void CSmsProtocol::PowerDown()
  1900     {
  1904     {
  1901     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_POWERDOWN_1, "CSmsProtocol::PowerDown");
  1905     LOGSMSPROT1("CSmsProtocol::PowerDown");
  1902     
  1906     
  1903     iSetBearer->Cancel();
  1907     iSetBearer->Cancel();
  1904     iReceiveMode->Cancel();
  1908     iReceiveMode->Cancel();
  1905     
  1909     
  1906     iSendQueue->Cancel();
  1910     iSendQueue->Cancel();
  1927     iWriteQueue = NULL;
  1931     iWriteQueue = NULL;
  1928     
  1932     
  1929     delete iDeleteQueue; //must be deleted because uses iSmsMessaging which is soon closed
  1933     delete iDeleteQueue; //must be deleted because uses iSmsMessaging which is soon closed
  1930     iDeleteQueue = NULL;
  1934     iDeleteQueue = NULL;
  1931     
  1935     
  1932     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_POWERDOWN_2, "CSmsProtocol::PowerDown  Cancelled state machines");
  1936     LOGSMSPROT1("CSmsProtocol::PowerDown  Cancelled state machines");
  1933     
  1937     
  1934     NotifyMessageObservers(KIoctlSelectModemNotPresent);
  1938     NotifyMessageObservers(KIoctlSelectModemNotPresent);
  1935     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_POWERDOWN_3, "CSmsProtocol::PowerDown  Notified message observers");
  1939     LOGSMSPROT1("CSmsProtocol::PowerDown  Notified message observers");
  1936     
  1940     
  1937     // Close TSY handles
  1941     // Close TSY handles
  1938     iSmsMessaging.Close();
  1942     iSmsMessaging.Close();
  1939     iGsmPhone.Close();
  1943     iGsmPhone.Close();
  1940     iEnumerationPhone.Close();
  1944     iEnumerationPhone.Close();
  1941     iWritePhone.Close();
  1945     iWritePhone.Close();
  1942     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_POWERDOWN_4, "CSmsProtocol::PowerDown  Closed TSY handles");
  1946     LOGSMSPROT1("CSmsProtocol::PowerDown  Closed TSY handles");
  1943     
  1947     
  1944     // Disconnect from Etel
  1948     // Disconnect from Etel
  1945     iTelServer.Close();
  1949     iTelServer.Close();
  1946     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_POWERDOWN_5, "CSmsProtocol::PowerDown  Disconnected from Etel");
  1950     LOGSMSPROT1("CSmsProtocol::PowerDown  Disconnected from Etel");
  1947     
  1951     
  1948     iReassemblyStore->Close();
  1952     iReassemblyStore->Close();
  1949     iSegmentationStore->Close();
  1953     iSegmentationStore->Close();
  1950     
  1954     
  1951     iState = EPoweredDown;
  1955     iState = EPoweredDown;
  1957     // empty and SMS stack is closing down - can only get this situation
  1961     // empty and SMS stack is closing down - can only get this situation
  1958     // when the PDU delete has been initiated by the SMS stack itself 
  1962     // when the PDU delete has been initiated by the SMS stack itself 
  1959     // (rather than the client) and the PDUs are still being deleted 
  1963     // (rather than the client) and the PDUs are still being deleted 
  1960     // when last client disconnects.
  1964     // when last client disconnects.
  1961     BULLSEYE_OFF
  1965     BULLSEYE_OFF
  1962     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_CLOSENOWWRAP_1, "CSmsProtocol::CloseNowWrap()");
  1966     LOGSMSPROT1("CSmsProtocol::CloseNowWrap()");
  1963     
  1967     
  1964     if( iDeleteQueue == NULL || !iDeleteQueue->IsActive() )
  1968     if( iDeleteQueue == NULL || !iDeleteQueue->IsActive() )
  1965         {
  1969         {
  1966         CloseNow();
  1970         CloseNow();
  1967         }
  1971         }
  1968     BULLSEYE_RESTORE
  1972     BULLSEYE_RESTORE
  1969     }
  1973     }
  1970 
  1974 
  1971 void CSmsProtocol::HandleBackupOrRestoreStartingL()
  1975 void CSmsProtocol::HandleBackupOrRestoreStartingL()
  1972     {
  1976     {
  1973     OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_HANDLEBACKUPORRESTORESTARTINGL_1, "CSmsProtocol::HandleBackupOrRestoreStartingL [ModemState=%d]",  iSmsModemNotification->ModemState());
  1977     LOGSMSPROT2("CSmsProtocol::HandleBackupOrRestoreStartingL [ModemState=%d]",  iSmsModemNotification->ModemState());
  1974     PowerDown();
  1978     PowerDown();
  1975     }
  1979     }
  1976 
  1980 
  1977 void CSmsProtocol::HandleBackupOrRestoreCompleteL()
  1981 void CSmsProtocol::HandleBackupOrRestoreCompleteL()
  1978     {
  1982     {
  1979     OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_HANDLEBACKUPORRESTORECOMPLETEL_1, "CSmsProtocol::HandleBackupOrRestoreCompleteL [ModemState=%d]", iSmsModemNotification->ModemState());
  1983     LOGSMSPROT2("CSmsProtocol::HandleBackupOrRestoreCompleteL [ModemState=%d]", iSmsModemNotification->ModemState());
  1980     
  1984     
  1981     if (iModemDetection == RPhone::EDetectedPresent)
  1985     if (iModemDetection == RPhone::EDetectedPresent)
  1982         {
  1986         {
  1983         PowerUp();
  1987         PowerUp();
  1984         }
  1988         }
  1987 /**
  1991 /**
  1988  *  Set the sap port number
  1992  *  Set the sap port number
  1989  */
  1993  */
  1990 TBool CSmsProtocol::AllocateLocalAddress(TSmsAddr& aAddr)
  1994 TBool CSmsProtocol::AllocateLocalAddress(TSmsAddr& aAddr)
  1991 	{
  1995 	{
  1992     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_ALLOCATELOCALADDRESS_1, "CSmsProtocol::AllocateLocalAddressL");
  1996     LOGSMSPROT1("CSmsProtocol::AllocateLocalAddressL");
  1993 
  1997 
  1994 	TBool found=EFalse;
  1998 	TBool found=EFalse;
  1995 	TUint count=0,attempts=0;
  1999 	TUint count=0,attempts=0;
  1996 	TSmsAddr locAddr=aAddr;
  2000 	TSmsAddr locAddr=aAddr;
  1997 
  2001 
  2035  *  @param aSmsMessage reference to CSmsMessage object.
  2039  *  @param aSmsMessage reference to CSmsMessage object.
  2036  *  
  2040  *  
  2037  */
  2041  */
  2038 TBool CSmsProtocol::IsAppPortSMS(const CSmsMessage& aSmsMessage)
  2042 TBool CSmsProtocol::IsAppPortSMS(const CSmsMessage& aSmsMessage)
  2039 	{
  2043 	{
  2040 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_ISAPPPORTSMS_1, "CSmsProtocol::IsAppPortSMS()");
  2044 	LOGSMSPROT1("CSmsProtocol::IsAppPortSMS()");
  2041 
  2045 
  2042 	TSmsAddr addr;
  2046 	TSmsAddr addr;
  2043 	addr.SetSmsAddrFamily(ESmsAddrMatchIEI);
  2047 	addr.SetSmsAddrFamily(ESmsAddrMatchIEI);
  2044 	addr.SetIdentifierMatch(CSmsInformationElement::ESmsIEIApplicationPortAddressing8Bit);
  2048 	addr.SetIdentifierMatch(CSmsInformationElement::ESmsIEIApplicationPortAddressing8Bit);
  2045 	if (IsMatch(addr,aSmsMessage))
  2049 	if (IsMatch(addr,aSmsMessage))
  2065 	} // CSmsProtocol::IsAppPortSMS
  2069 	} // CSmsProtocol::IsAppPortSMS
  2066 
  2070 
  2067 
  2071 
  2068 const RMobilePhone::TMobilePhoneNetworkInfoV1& CSmsProtocol::NetworkInfo() const
  2072 const RMobilePhone::TMobilePhoneNetworkInfoV1& CSmsProtocol::NetworkInfo() const
  2069 	{
  2073 	{
  2070 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_NETWORKINFO_1, "CSmsProtocol::NetworkInfo()");
  2074 	LOGSMSPROT1("CSmsProtocol::NetworkInfo()");
  2071 
  2075 
  2072 	return iSmsPhoneInitialization->NetworkInfo();
  2076 	return iSmsPhoneInitialization->NetworkInfo();
  2073 	} // CSmsProtocol::NetworkInfo
  2077 	} // CSmsProtocol::NetworkInfo
  2074 
  2078 
  2075 
  2079 
  2076 TBool CSmsProtocol::NetworkInfoAvailable() const
  2080 TBool CSmsProtocol::NetworkInfoAvailable() const
  2077 	{
  2081 	{
  2078 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOL_NETWORKINFOAVAILABLE_1, "CSmsProtocol::NetworkInfoAvailable()");
  2082 	LOGSMSPROT1("CSmsProtocol::NetworkInfoAvailable()");
  2079 
  2083 
  2080 	return iSmsPhoneInitialization->NetworkInfoAvailable();
  2084 	return iSmsPhoneInitialization->NetworkInfoAvailable();
  2081 	} // CSmsProtocol::NetworkInfoAvailable
  2085 	} // CSmsProtocol::NetworkInfoAvailable
  2082 
  2086 
  2083 
  2087 
  2089  *  
  2093  *  
  2090  *  @param aActive Reference to an CSmsProtocol object
  2094  *  @param aActive Reference to an CSmsProtocol object
  2091  */
  2095  */
  2092 CSmsProtocolBootTimer* CSmsProtocolBootTimer::NewL(CSmsProtocol& aSmsProtocol)
  2096 CSmsProtocolBootTimer* CSmsProtocolBootTimer::NewL(CSmsProtocol& aSmsProtocol)
  2093     {
  2097     {
  2094     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOLBOOTTIMER_NEWL_1, "CSmsProtocolBootTimer::NewL");
  2098     LOGSMSPROT1("CSmsProtocolBootTimer::NewL");
  2095     
  2099     
  2096     CSmsProtocolBootTimer* self = new(ELeave) CSmsProtocolBootTimer(aSmsProtocol);
  2100     CSmsProtocolBootTimer* self = new(ELeave) CSmsProtocolBootTimer(aSmsProtocol);
  2097     CleanupStack::PushL(self);
  2101     CleanupStack::PushL(self);
  2098     self->ConstructL();
  2102     self->ConstructL();
  2099     CleanupStack::Pop(self);
  2103     CleanupStack::Pop(self);
  2111 /**
  2115 /**
  2112  *  Start a timeout specified in aTimeIntervalMicroSeconds32
  2116  *  Start a timeout specified in aTimeIntervalMicroSeconds32
  2113  */
  2117  */
  2114 void CSmsProtocolBootTimer::Start(const TTimeIntervalMicroSeconds32& aTimeIntervalMicroSeconds32)
  2118 void CSmsProtocolBootTimer::Start(const TTimeIntervalMicroSeconds32& aTimeIntervalMicroSeconds32)
  2115 	{
  2119 	{
  2116 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOLBOOTTIMER_START_1, "CSmsProtocolBootTimer::Start");
  2120 	LOGSMSPROT1("CSmsProtocolBootTimer::Start");
  2117 	After(aTimeIntervalMicroSeconds32);
  2121 	After(aTimeIntervalMicroSeconds32);
  2118 	}
  2122 	}
  2119 
  2123 
  2120 /**
  2124 /**
  2121  *  C'tor
  2125  *  C'tor
  2129 /**
  2133 /**
  2130  *  Timer completed - cancel the observer
  2134  *  Timer completed - cancel the observer
  2131  */
  2135  */
  2132 void CSmsProtocolBootTimer::RunL()
  2136 void CSmsProtocolBootTimer::RunL()
  2133     {
  2137     {
  2134     OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPROTOCOLBOOTTIMER_RUNL_1, "CSmsProtocolBootTimer::RunL [iStatus=%d]", iStatus.Int() );
  2138     LOGSMSPROT2("CSmsProtocolBootTimer::RunL [iStatus=%d]", iStatus.Int() );
  2135     iSmsProtocol.MessageReadedSuccessfully();
  2139     iSmsProtocol.MessageReadedSuccessfully();
  2136     }
  2140     }