telephonyserverplugins/simatktsy/src/CSatNotifySendSm.cpp
branchRCL_3
changeset 65 630d2f34d719
parent 0 3553901f7fa8
child 66 07a122eea281
equal deleted inserted replaced
61:17af172ffa5f 65:630d2f34d719
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2005-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".
    18 //
    18 //
    19 
    19 
    20 
    20 
    21 
    21 
    22 //INCLUDES
    22 //INCLUDES
       
    23 
       
    24 #include "OstTraceDefinitions.h"
       
    25 #ifdef OST_TRACE_COMPILER_IN_USE
       
    26 #include "CSatNotifySendSmTraces.h"
       
    27 #endif
       
    28 
    23 #include <satcs.h>                  // Etel SAT IPC definitions
    29 #include <satcs.h>                  // Etel SAT IPC definitions
    24 #include "CSatTsy.h"                // Tsy class header
    30 #include "CSatTsy.h"                // Tsy class header
    25 #include "CSatNotifySendSm.h"       // Tsy class header
    31 #include "CSatNotifySendSm.h"       // Tsy class header
    26 #include "CSatNotificationsTsy.h"   // Class header
    32 #include "CSatNotificationsTsy.h"   // Class header
    27 #include "CBerTlv.h"                // Ber Tlv data handling
    33 #include "CBerTlv.h"                // Ber Tlv data handling
    28 #include "TTlv.h"					// TTlv class
    34 #include "TTlv.h"					// TTlv class
    29 #include "CSatDataPackage.h"        // Parameter packing 
    35 #include "CSatDataPackage.h"        // Parameter packing 
    30 #include "TfLogger.h"               // For TFLOGSTRING
       
    31 #include "TSatUtility.h"            // Utilities
    36 #include "TSatUtility.h"            // Utilities
    32 #include "CSatTsyReqHandleStore.h"  // Request handle class
    37 #include "CSatTsyReqHandleStore.h"  // Request handle class
    33 #include "cmmmessagemanagerbase.h"  // Message manager class for forwarding req.
    38 #include "cmmmessagemanagerbase.h"  // Message manager class for forwarding req.
    34 
    39 
    35 // -----------------------------------------------------------------------------
    40 // -----------------------------------------------------------------------------
    40 CSatNotifySendSm* CSatNotifySendSm::NewL
    45 CSatNotifySendSm* CSatNotifySendSm::NewL
    41         ( 
    46         ( 
    42         CSatNotificationsTsy* aNotificationsTsy 
    47         CSatNotificationsTsy* aNotificationsTsy 
    43         )
    48         )
    44     {
    49     {
    45     TFLOGSTRING("CSAT: CSatNotifySendSm::NewL");
    50     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSM_NEWL_1, "CSAT: CSatNotifySendSm::NewL");
    46    	CSatNotifySendSm* const satNotifySendSm = 
    51    	CSatNotifySendSm* const satNotifySendSm = 
    47         new ( ELeave ) CSatNotifySendSm( aNotificationsTsy );
    52         new ( ELeave ) CSatNotifySendSm( aNotificationsTsy );
    48     CleanupStack::PushL( satNotifySendSm );
    53     CleanupStack::PushL( satNotifySendSm );
    49     satNotifySendSm->ConstructL();
    54     satNotifySendSm->ConstructL();
    50     CleanupStack::Pop( satNotifySendSm );
    55     CleanupStack::Pop( satNotifySendSm );
    51     TFLOGSTRING("CSAT: CSatNotifySendSm::NewL, end of method");
    56     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSM_NEWL_2, "CSAT: CSatNotifySendSm::NewL, end of method");
    52     return satNotifySendSm;
    57     return satNotifySendSm;
    53     }
    58     }
    54 
    59 
    55 // -----------------------------------------------------------------------------
    60 // -----------------------------------------------------------------------------
    56 // CSatNotifySendSm::~CSatNotifySendSm
    61 // CSatNotifySendSm::~CSatNotifySendSm
    60 CSatNotifySendSm::~CSatNotifySendSm
    65 CSatNotifySendSm::~CSatNotifySendSm
    61         ( 
    66         ( 
    62 		// None
    67 		// None
    63         )
    68         )
    64     {
    69     {
    65     TFLOGSTRING("CSAT: CSatNotifySendSm::~CSatNotifySendSm");
    70     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSM_DTOR_1, "CSAT: CSatNotifySendSm::~CSatNotifySendSm");
    66     }
    71     }
    67     
    72     
    68 // -----------------------------------------------------------------------------
    73 // -----------------------------------------------------------------------------
    69 // CSatNotifySendSm::CSatNotifySendSm
    74 // CSatNotifySendSm::CSatNotifySendSm
    70 // Default C++ constructor
    75 // Default C++ constructor
    86 void CSatNotifySendSm::ConstructL
    91 void CSatNotifySendSm::ConstructL
    87         (
    92         (
    88         // None
    93         // None
    89         )
    94         )
    90     {
    95     {
    91     TFLOGSTRING("CSAT: CSatNotifySendSm::ConstructL, does nothing");
    96     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSM_CONSTRUCTL_1, "CSAT: CSatNotifySendSm::ConstructL, does nothing");
    92     }
    97     }
    93     
    98     
    94 // -----------------------------------------------------------------------------
    99 // -----------------------------------------------------------------------------
    95 // CSatNotifySendSm::Notify
   100 // CSatNotifySendSm::Notify
    96 // This request allows a client to be notified of a Send Sm proactive command.
   101 // This request allows a client to be notified of a Send Sm proactive command.
   100         (
   105         (
   101         const TTsyReqHandle aTsyReqHandle,
   106         const TTsyReqHandle aTsyReqHandle,
   102         const TDataPackage& aPackage
   107         const TDataPackage& aPackage
   103         )
   108         )
   104     {
   109     {
   105     TFLOGSTRING("CSAT: CSatNotifySendSm::Notify");
   110     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSM_NOTIFY_1, "CSAT: CSatNotifySendSm::Notify");
   106     // Save data pointer to client side for completion
   111     // Save data pointer to client side for completion
   107     iSendSmV1Pckg = reinterpret_cast<RSat::TSendSmV1Pckg*>( 
   112     iSendSmV1Pckg = reinterpret_cast<RSat::TSendSmV1Pckg*>( 
   108         aPackage.Des1n() );
   113         aPackage.Des1n() );
   109     // Save the request handle
   114     // Save the request handle
   110     iNotificationsTsy->iSatTsy->SaveReqHandle( aTsyReqHandle, 
   115     iNotificationsTsy->iSatTsy->SaveReqHandle( aTsyReqHandle, 
   122 TInt CSatNotifySendSm::CancelNotification
   127 TInt CSatNotifySendSm::CancelNotification
   123         (
   128         (
   124         const TTsyReqHandle aTsyReqHandle 
   129         const TTsyReqHandle aTsyReqHandle 
   125         )
   130         )
   126     {
   131     {
   127     TFLOGSTRING("CSAT: CSatNotifySendSm::CancelNotification");   
   132     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSM_CANCELNOTIFICATION_1, "CSAT: CSatNotifySendSm::CancelNotification");
   128     // Reset the request handle
   133     // Reset the request handle
   129     TTsyReqHandle reqHandle = iNotificationsTsy->iSatReqHandleStore->
   134     TTsyReqHandle reqHandle = iNotificationsTsy->iSatReqHandleStore->
   130         ResetTsyReqHandle( CSatTsy::ESatNotifySendSmPCmdReqType );
   135         ResetTsyReqHandle( CSatTsy::ESatNotifySendSmPCmdReqType );
   131 	// Reset the data pointer
   136 	// Reset the data pointer
   132 	iSendSmV1Pckg = NULL;
   137 	iSendSmV1Pckg = NULL;
   145         (
   150         (
   146         CSatDataPackage* aDataPackage,  
   151         CSatDataPackage* aDataPackage,  
   147         TInt aErrorCode                 
   152         TInt aErrorCode                 
   148         )
   153         )
   149     {
   154     {
   150     TFLOGSTRING("CSAT: CSatNotifySendSm::CompleteNotifyL");
   155     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSM_COMPLETENOTIFYL_1, "CSAT: CSatNotifySendSm::CompleteNotifyL");
   151     TInt ret( KErrNone );
   156     TInt ret( KErrNone );
   152 	TBuf<1> additionalInfo;
   157 	TBuf<1> additionalInfo;
   153 	// Unpack parameters
   158 	// Unpack parameters
   154     TPtrC8* data;
   159     TPtrC8* data;
   155     aDataPackage->UnPackData( &data );
   160     aDataPackage->UnPackData( &data );
   193 				// Check that TP-UDL is valid
   198 				// Check that TP-UDL is valid
   194 				ret = CheckTpdu( smsTpdu );
   199 				ret = CheckTpdu( smsTpdu );
   195 				
   200 				
   196 				if ( KErrCorrupt == ret )
   201 				if ( KErrCorrupt == ret )
   197 					{
   202 					{
   198 					TFLOGSTRING("CSAT: CSatNotifySendSm::CompleteNotifyL,\
   203 					OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSM_COMPLETENOTIFYL_2, "CSAT: CSatNotifySendSm::CompleteNotifyL, Invalid data");
   199 					    Invalid data");
       
   200 					additionalInfo.Zero();
   204 					additionalInfo.Zero();
   201                     additionalInfo.Append( KNoCause );
   205                     additionalInfo.Append( KNoCause );
   202 					CreateTerminalRespL( pCmdNumber, 
   206 					CreateTerminalRespL( pCmdNumber, 
   203 					    RSat::KCmdDataNotUnderstood, additionalInfo );                            
   207 					    RSat::KCmdDataNotUnderstood, additionalInfo );                            
   204                     }
   208                     }
   219 						{
   223 						{
   220 						// Call method to pack sms
   224 						// Call method to pack sms
   221 						ret = PackSms( smsTpdu, sendSmV1.iSmsTpdu );
   225 						ret = PackSms( smsTpdu, sendSmV1.iSmsTpdu );
   222 						if ( KErrNone != ret )
   226 						if ( KErrNone != ret )
   223 							{
   227 							{
   224 							TFLOGSTRING("CSAT: CSatNotifySendSm::\
   228 							OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSM_COMPLETENOTIFYL_3, "CSAT: CSatNotifySendSm::CompleteNotifyL, Invalid TPDU");
   225 							    CompleteNotifyL, Invalid TPDU");
       
   226 							// TPDU is invalid or packing cannot be requested 
   229 							// TPDU is invalid or packing cannot be requested 
   227 							// if tpdu is something else than SMS-SUBMIT
   230 							// if tpdu is something else than SMS-SUBMIT
   228 							additionalInfo.Zero();
   231 							additionalInfo.Zero();
   229                             additionalInfo.Append( KNoCause );
   232                             additionalInfo.Append( KNoCause );
   230 							CreateTerminalRespL( pCmdNumber,                  
   233 							CreateTerminalRespL( pCmdNumber,                  
   236 							// Do nothing
   239 							// Do nothing
   237 							}					
   240 							}					
   238 						}
   241 						}
   239 					else
   242 					else
   240 						{
   243 						{
   241 						TFLOGSTRING("CSAT: CSatNotifySendSm::CompleteNotifyL,\
   244 						OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSM_COMPLETENOTIFYL_4, "CSAT: CSatNotifySendSm::CompleteNotifyL, Packing not required");
   242 						    Packing not required");
       
   243 						}
   245 						}
   244 					}
   246 					}
   245 				else
   247 				else
   246 					{
   248 					{
   247 					// Do nothing
   249 					// Do nothing
   248 					}
   250 					}
   249 				}
   251 				}
   250 			else
   252 			else
   251 				{
   253 				{
   252 				TFLOGSTRING("CSAT: CSatNotifySendSm::CompleteNotifyL,\
   254 				OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSM_COMPLETENOTIFYL_5, "CSAT: CSatNotifySendSm::CompleteNotifyL, Missing TPDU");
   253 				    Missing TPDU");
       
   254 				// TPdu is missing, returning response immediately
   255 				// TPdu is missing, returning response immediately
   255 				additionalInfo.Zero();
   256 				additionalInfo.Zero();
   256                 additionalInfo.Append( KNoCause );
   257                 additionalInfo.Append( KNoCause );
   257 				CreateTerminalRespL( pCmdNumber, 
   258 				CreateTerminalRespL( pCmdNumber, 
   258 				    RSat::KErrorRequiredValuesMissing, additionalInfo );
   259 				    RSat::KErrorRequiredValuesMissing, additionalInfo );
   275         iNotificationsTsy->iSatTsy->ReqCompleted( reqHandle, ret );   
   276         iNotificationsTsy->iSatTsy->ReqCompleted( reqHandle, ret );   
   276         	
   277         	
   277         } // End of if ( CSatTsy::ESatReqHandleUnknown != reqHandle )
   278         } // End of if ( CSatTsy::ESatReqHandleUnknown != reqHandle )
   278 	else
   279 	else
   279 		{
   280 		{
   280 		TFLOGSTRING("CSAT: CSatNotifySendSm::CompleteNotifyL,\
   281 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSM_COMPLETENOTIFYL_6, "CSAT: CSatNotifySendSm::CompleteNotifyL, Request not ongoing");
   281 		    Request not ongoing");
       
   282 		// Request not on, returning response immediately
   282 		// Request not on, returning response immediately
   283 		additionalInfo.Zero();
   283 		additionalInfo.Zero();
   284         additionalInfo.Append( KNoCause );       
   284         additionalInfo.Append( KNoCause );       
   285 		CreateTerminalRespL( pCmdNumber, RSat::KMeUnableToProcessCmd, 
   285 		CreateTerminalRespL( pCmdNumber, RSat::KMeUnableToProcessCmd, 
   286 			additionalInfo );					 
   286 			additionalInfo );					 
   296 TInt CSatNotifySendSm::TerminalResponseL
   296 TInt CSatNotifySendSm::TerminalResponseL
   297         (
   297         (
   298         TDes8* aRsp 
   298         TDes8* aRsp 
   299         )
   299         )
   300     {  
   300     {  
   301     TFLOGSTRING( "CSAT::CSatNotifySendSm::TerminalResponseL" );
   301     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSM_TERMINALRESPONSEL_1,  "CSAT::CSatNotifySendSm::TerminalResponseL" );
   302     
   302     
   303     TInt ret( KErrNone );
   303     TInt ret( KErrNone );
   304     TBuf<1> additionalInfo;
   304     TBuf<1> additionalInfo;
   305     RSat::TSendSmRspV1Pckg* aRspPckg = 
   305     RSat::TSendSmRspV1Pckg* aRspPckg = 
   306         reinterpret_cast<RSat::TSendSmRspV1Pckg*>( aRsp );
   306         reinterpret_cast<RSat::TSendSmRspV1Pckg*>( aRsp );
   307     RSat::TSendSmRspV1& rspV1 = ( *aRspPckg ) ();
   307     RSat::TSendSmRspV1& rspV1 = ( *aRspPckg ) ();
   308     // Get Proactive command number
   308     // Get Proactive command number
   309     TUint8 pCmdNumber( rspV1.PCmdNumber() );
   309     TUint8 pCmdNumber( rspV1.PCmdNumber() );
   310     TFLOGSTRING2( "CSAT::CSatNotifySendSm::TerminalResponseL: GeneralResult: \
   310     OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSM_TERMINALRESPONSEL_2,  "CSAT::CSatNotifySendSm::TerminalResponseL: GeneralResult: %d", static_cast<TUint8>( rspV1.iGeneralResult ) );
   311         %d", static_cast<TUint8>( rspV1.iGeneralResult ) );
       
   312 
   311 
   313     // Check that general result value is valid
   312     // Check that general result value is valid
   314     if ( ( RSat::KSuccess != rspV1.iGeneralResult ) && 
   313     if ( ( RSat::KSuccess != rspV1.iGeneralResult ) && 
   315          ( RSat::KMeUnableToProcessCmd  != rspV1.iGeneralResult ) && 
   314          ( RSat::KMeUnableToProcessCmd  != rspV1.iGeneralResult ) && 
   316          ( RSat::KCmdBeyondMeCapabilities != rspV1.iGeneralResult )&& 
   315          ( RSat::KCmdBeyondMeCapabilities != rspV1.iGeneralResult )&& 
   317          ( RSat::KSmsRpError != rspV1.iGeneralResult ) && 
   316          ( RSat::KSmsRpError != rspV1.iGeneralResult ) && 
   318          ( RSat::KInteractionWithCCPermanentError != rspV1.iGeneralResult ) && 
   317          ( RSat::KInteractionWithCCPermanentError != rspV1.iGeneralResult ) && 
   319          ( RSat::KModifiedByCallControl != rspV1.iGeneralResult ) && 
   318          ( RSat::KModifiedByCallControl != rspV1.iGeneralResult ) && 
   320          ( RSat::KSuccessRequestedIconNotDisplayed != rspV1.iGeneralResult ) )        
   319          ( RSat::KSuccessRequestedIconNotDisplayed != rspV1.iGeneralResult ) )        
   321         {
   320         {
   322         TFLOGSTRING( "CSAT::CSatNotifySendSm::TerminalResponseL,\
   321         OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSM_TERMINALRESPONSEL_3,  "CSAT::CSatNotifySendSm::TerminalResponseL, Invalid General result" );
   323             Invalid General result" );
       
   324         // Invalid general result
   322         // Invalid general result
   325         ret = KErrCorrupt;
   323         ret = KErrCorrupt;
   326         }
   324         }
   327 
   325 
   328     // If there is ME (Mobile Entity) error or network error, additional info
   326     // If there is ME (Mobile Entity) error or network error, additional info
   332          ( RSat::KControlInteraction == rspV1.iInfoType ) )        
   330          ( RSat::KControlInteraction == rspV1.iInfoType ) )        
   333         {
   331         {
   334         // Check the length of additional info
   332         // Check the length of additional info
   335         if ( 0 == rspV1.iAdditionalInfo.Length() )
   333         if ( 0 == rspV1.iAdditionalInfo.Length() )
   336             {
   334             {
   337             TFLOGSTRING( "CSAT::CSatNotifySendSm::TerminalResponseL,\
   335             OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSM_TERMINALRESPONSEL_4,  "CSAT::CSatNotifySendSm::TerminalResponseL, Invalid Additional Info" );
   338                 Invalid Additional Info" );
       
   339             // No info
   336             // No info
   340             ret = KErrCorrupt;
   337             ret = KErrCorrupt;
   341             }
   338             }
   342         else
   339         else
   343             {
   340             {
   369         TUint8 aPCmdNumber,        
   366         TUint8 aPCmdNumber,        
   370         TUint8 aGeneralResult,      
   367         TUint8 aGeneralResult,      
   371         TDesC16& aAdditionalInfo		
   368         TDesC16& aAdditionalInfo		
   372 		)
   369 		)
   373     {
   370     {
   374     TFLOGSTRING( "CSAT::CSatNotifySendSm::CreateTerminalRespL" );
   371     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSM_CREATETERMINALRESPL_1,  "CSAT::CSatNotifySendSm::CreateTerminalRespL" );
   375     // Create and append response data
   372     // Create and append response data
   376     TTlv tlvSpecificData;
   373     TTlv tlvSpecificData;
   377     // Create General Result TLV here
   374     // Create General Result TLV here
   378     tlvSpecificData.AddTag( KTlvResultTag );
   375     tlvSpecificData.AddTag( KTlvResultTag );
   379     // General result
   376     // General result
   384          ( RSat::KSmsRpError == aGeneralResult ) ||
   381          ( RSat::KSmsRpError == aGeneralResult ) ||
   385          ( RSat::KInteractionWithCCPermanentError == aGeneralResult ) )
   382          ( RSat::KInteractionWithCCPermanentError == aGeneralResult ) )
   386         {
   383         {
   387 		if( aAdditionalInfo.Length() > 0 )
   384 		if( aAdditionalInfo.Length() > 0 )
   388 	        {
   385 	        {
   389 	        TFLOGSTRING( "CSAT::CSatNotifySendSm::CreateTerminalRespL,\
   386 	        OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSM_CREATETERMINALRESPL_2,  "CSAT::CSatNotifySendSm::CreateTerminalRespL, Unsuccessful result" );
   390 	            Unsuccessful result" );
       
   391 	        // If there is ME, Network or SMS error, append additional info
   387 	        // If there is ME, Network or SMS error, append additional info
   392 	        tlvSpecificData.AddByte( static_cast<TUint8>( aAdditionalInfo[0] ) );
   388 	        tlvSpecificData.AddByte( static_cast<TUint8>( aAdditionalInfo[0] ) );
   393 	        }
   389 	        }
   394 		}
   390 		}
   395     else
   391     else
   417 		(
   413 		(
   418 		CBerTlv* aBerTlv,
   414 		CBerTlv* aBerTlv,
   419 		RSat::TSendSmV1& aSendSmV1
   415 		RSat::TSendSmV1& aSendSmV1
   420 		)
   416 		)
   421 	{
   417 	{
   422 	TFLOGSTRING( "CSAT::CSatNotifySendSm::SetAlphaIdAndAddressData" );
   418 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSM_SETALPHAIDANDADDRESSDATA_1,  "CSAT::CSatNotifySendSm::SetAlphaIdAndAddressData" );
   423 	TInt returnValue;
   419 	TInt returnValue;
   424 	TPtrC8 sourceString; // Used in unicode conversions
   420 	TPtrC8 sourceString; // Used in unicode conversions
   425 	// Alpha id string (optional)
   421 	// Alpha id string (optional)
   426 	aSendSmV1.iAlphaId.iAlphaId.Zero();
   422 	aSendSmV1.iAlphaId.iAlphaId.Zero();
   427 	CTlv alphaIdTlv;
   423 	CTlv alphaIdTlv;
   445 			{
   441 			{
   446 			aSendSmV1.iAlphaId.iStatus = RSat::EAlphaIdProvided;
   442 			aSendSmV1.iAlphaId.iStatus = RSat::EAlphaIdProvided;
   447 			}
   443 			}
   448 		else
   444 		else
   449 			{
   445 			{
   450 			TFLOGSTRING( "CSAT::CSatNotifySendSm::SetAlphaIdAndAddressData,\
   446 			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSM_SETALPHAIDANDADDRESSDATA_2,  "CSAT::CSatNotifySendSm::SetAlphaIdAndAddressData, Alpha ID is NULL" );
   451 			    Alpha ID is NULL" );
       
   452 			aSendSmV1.iAlphaId.iStatus = RSat::EAlphaIdNull;
   447 			aSendSmV1.iAlphaId.iStatus = RSat::EAlphaIdNull;
   453 			}
   448 			}
   454 		}
   449 		}
   455 	else 
   450 	else 
   456 		{
   451 		{
   457 		TFLOGSTRING( "CSAT::CSatNotifySendSm::SetAlphaIdAndAddressData,\
   452 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSM_SETALPHAIDANDADDRESSDATA_3,  "CSAT::CSatNotifySendSm::SetAlphaIdAndAddressData, Alpha ID not present" );
   458 		    Alpha ID not present" );
       
   459 		aSendSmV1.iAlphaId.iStatus = RSat::EAlphaIdNotPresent;
   453 		aSendSmV1.iAlphaId.iStatus = RSat::EAlphaIdNotPresent;
   460 		}
   454 		}
   461 	// The address data object holds the RP_Destination_Address of the Service 
   455 	// The address data object holds the RP_Destination_Address of the Service 
   462 	// Centre. If no RP_Destination_Address is transferred, then the ME shall 
   456 	// Centre. If no RP_Destination_Address is transferred, then the ME shall 
   463 	// insert the default Service Centre address (below).
   457 	// insert the default Service Centre address (below).
   489 				{
   483 				{
   490 				// Semi-octet presentation used
   484 				// Semi-octet presentation used
   491 				// Converting back to ASCII format
   485 				// Converting back to ASCII format
   492 				TSatUtility::BCDToAscii( sourceString, tempScaNumber );
   486 				TSatUtility::BCDToAscii( sourceString, tempScaNumber );
   493 				aSendSmV1.iAddress.iTelNumber.Copy( tempScaNumber );
   487 				aSendSmV1.iAddress.iTelNumber.Copy( tempScaNumber );
   494 				TFLOGSTRING2("CSAT: SendSm, SCA number: %S", 
   488 				OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSM_SETALPHAIDANDADDRESSDATA_4, "CSAT: SendSm, SCA number: %S", aSendSmV1.iAddress.iTelNumber );
   495 					&aSendSmV1.iAddress.iTelNumber );
       
   496 				}
   489 				}
   497        		else
   490        		else
   498       			{
   491       			{
   499       			TFLOGSTRING( "CSAT::CSatNotifySendSm::SetAlphaIdAndAddressData\
   492       			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSM_SETALPHAIDANDADDRESSDATA_5,  "CSAT::CSatNotifySendSm::SetAlphaIdAndAddressData Address TLV found, TON/NPI present, but number epmpty" );
   500       			    Address TLV found, TON/NPI present, but number epmpty" );
       
   501         		// Address TLV found, TON/NPI present, but number epmpty.
   493         		// Address TLV found, TON/NPI present, but number epmpty.
   502        			aSendSmV1.iAddress.iTypeOfNumber = RSat::EUnknownNumber;
   494        			aSendSmV1.iAddress.iTypeOfNumber = RSat::EUnknownNumber;
   503         		aSendSmV1.iAddress.iNumberPlan = RSat::EUnknownNumberingPlan;
   495         		aSendSmV1.iAddress.iNumberPlan = RSat::EUnknownNumberingPlan;
   504       			}
   496       			}
   505 		    }
   497 		    }
   506 		else
   498 		else
   507 		    {
   499 		    {
   508 		    TFLOGSTRING( "CSAT::CSatNotifySendSm::SetAlphaIdAndAddressData\
   500 		    OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSM_SETALPHAIDANDADDRESSDATA_6,  "CSAT::CSatNotifySendSm::SetAlphaIdAndAddressData Address TLV found, but the Value part doesn't exist");
   509 		        Address TLV found, but the Value part doesn't exist");
       
   510 		    // Address TLV found, but the Value part doesn't exist
   501 		    // Address TLV found, but the Value part doesn't exist
   511 		    aSendSmV1.iAddress.iTypeOfNumber = RSat::EUnknownNumber;
   502 		    aSendSmV1.iAddress.iTypeOfNumber = RSat::EUnknownNumber;
   512 		    aSendSmV1.iAddress.iNumberPlan = RSat::EUnknownNumberingPlan;
   503 		    aSendSmV1.iAddress.iNumberPlan = RSat::EUnknownNumberingPlan;
   513 		    }
   504 		    }
   514 		}
   505 		}
   515 	else
   506 	else
   516 	    {
   507 	    {
   517 	    TFLOGSTRING( "CSAT::CSatNotifySendSm::SetAlphaIdAndAddressData\
   508 	    OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSM_SETALPHAIDANDADDRESSDATA_7,  "CSAT::CSatNotifySendSm::SetAlphaIdAndAddressData Address TLV not found");
   518 	        Address TLV not found");
       
   519 	    // Address TLV not found
   509 	    // Address TLV not found
   520 	    aSendSmV1.iAddress.iTypeOfNumber = RSat::ETypeOfNumberNotSet;
   510 	    aSendSmV1.iAddress.iTypeOfNumber = RSat::ETypeOfNumberNotSet;
   521 	    aSendSmV1.iAddress.iNumberPlan = RSat::ENumberingPlanNotSet;  
   511 	    aSendSmV1.iAddress.iNumberPlan = RSat::ENumberingPlanNotSet;  
   522 	    }	
   512 	    }	
   523 	}
   513 	}
   530 TInt CSatNotifySendSm::CheckTpdu
   520 TInt CSatNotifySendSm::CheckTpdu
   531 	    (
   521 	    (
   532 	    TPtrC8 aTpdu    
   522 	    TPtrC8 aTpdu    
   533 	    )
   523 	    )
   534     {
   524     {
   535     TFLOGSTRING( "CSAT::CSatNotifySendSm::CheckTpdu");
   525     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSM_CHECKTPDU_1,  "CSAT::CSatNotifySendSm::CheckTpdu");
   536     TInt ret( KErrNone );
   526     TInt ret( KErrNone );
   537 
   527 
   538     if ( KSATSmsMTISubmitOrSubmitReport == ( aTpdu[0] & KMask3 ) ) 
   528     if ( KSATSmsMTISubmitOrSubmitReport == ( aTpdu[0] & KMask3 ) ) 
   539         {
   529         {
   540         // SMS-SUBMIT
   530         // SMS-SUBMIT
   543         TUint8 dcs( GetTpDcs( aTpdu ) );
   533         TUint8 dcs( GetTpDcs( aTpdu ) );
   544         dcs &= KDCSAlphabetMask;
   534         dcs &= KDCSAlphabetMask;
   545         
   535         
   546         if ( !dcs && KSmsMaxSize < tpUdl )
   536         if ( !dcs && KSmsMaxSize < tpUdl )
   547             {
   537             {
   548             TFLOGSTRING( "CSAT::CSatNotifySendSm::CheckTpdu,\
   538             OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSM_CHECKTPDU_2,  "CSAT::CSatNotifySendSm::CheckTpdu, False DCS Length");
   549                 False DCS Length");
       
   550             // DCS is 7-bit and message is over 160 bytes, set ret to corrupt
   539             // DCS is 7-bit and message is over 160 bytes, set ret to corrupt
   551             ret = KErrCorrupt;
   540             ret = KErrCorrupt;
   552             }
   541             }
   553         else if ( ( !( KSmsPackingRequiredMask & iNotificationsTsy->
   542         else if ( ( !( KSmsPackingRequiredMask & iNotificationsTsy->
   554         	iTerminalRespData.iCommandDetails[KCommandQualifier] ) )
   543         	iTerminalRespData.iCommandDetails[KCommandQualifier] ) )
   555             && ( KSmsMaxSizeWithoutPacking < tpUdl && dcs ) )
   544             && ( KSmsMaxSizeWithoutPacking < tpUdl && dcs ) )
   556             {
   545             {
   557             TFLOGSTRING( "CSAT::CSatNotifySendSm::CheckTpdu,\
   546             OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSM_CHECKTPDU_3,  "CSAT::CSatNotifySendSm::CheckTpdu, TP-UD Too long without packing");
   558                 TP-UD Too long without packing");
       
   559             // TP-UD is too long without packing
   547             // TP-UD is too long without packing
   560             ret = KErrCorrupt;
   548             ret = KErrCorrupt;
   561             }
   549             }
   562         else if ( ( KSmsMaxSize < tpUdl ) && dcs )
   550         else if ( ( KSmsMaxSize < tpUdl ) && dcs )
   563             {
   551             {
   564             TFLOGSTRING( "CSAT::CSatNotifySendSm::CheckTpdu,\
   552             OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSM_CHECKTPDU_4,  "CSAT::CSatNotifySendSm::CheckTpdu, TP-UD is too long even with packing");
   565                 TP-UD is too long even with packing");
       
   566             // TP-UD is too long even with packing
   553             // TP-UD is too long even with packing
   567             ret = KErrCorrupt;
   554             ret = KErrCorrupt;
   568             }
   555             }
   569         else
   556         else
   570         	{
   557         	{
   574     else
   561     else
   575         {
   562         {
   576         // SMS-COMMAND
   563         // SMS-COMMAND
   577         if ( KSMSCommandMaxSize < GetTpUdl( aTpdu ) )
   564         if ( KSMSCommandMaxSize < GetTpUdl( aTpdu ) )
   578             {
   565             {
   579             TFLOGSTRING( "CSAT::CSatNotifySendSm::CheckTpdu,\
   566             OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSM_CHECKTPDU_5,  "CSAT::CSatNotifySendSm::CheckTpdu, False SMS Command length");
   580                 False SMS Command length");
       
   581             ret = KErrCorrupt;
   567             ret = KErrCorrupt;
   582             }
   568             }
   583 		else
   569 		else
   584 			{
   570 			{
   585 			// Do nothing
   571 			// Do nothing
   598 TUint8 CSatNotifySendSm::GetTpUdl
   584 TUint8 CSatNotifySendSm::GetTpUdl
   599 	    ( 
   585 	    ( 
   600 	    TPtrC8 aTpdu  
   586 	    TPtrC8 aTpdu  
   601 	    )
   587 	    )
   602     {
   588     {
   603     TFLOGSTRING( "CSAT::CSatNotifySendSm::GetTpUdl");
   589     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSM_GETTPUDL_1,  "CSAT::CSatNotifySendSm::GetTpUdl");
   604     TUint8 ret( 0 );
   590     TUint8 ret( 0 );
   605     if ( KSATSmsMTISubmitOrSubmitReport == ( aTpdu[0] & KMask3 ) )
   591     if ( KSATSmsMTISubmitOrSubmitReport == ( aTpdu[0] & KMask3 ) )
   606         {
   592         {
   607         // SMS-SUBMIT
   593         // SMS-SUBMIT
   608         // Calculate the startpos of TP-UD field,
   594         // Calculate the startpos of TP-UD field,
   673 TUint8 CSatNotifySendSm::GetTpDcs
   659 TUint8 CSatNotifySendSm::GetTpDcs
   674 	    ( 
   660 	    ( 
   675 	    TPtrC8 aTpdu 
   661 	    TPtrC8 aTpdu 
   676 	    )
   662 	    )
   677     {
   663     {
   678     TFLOGSTRING( "CSAT::CSatNotifySendSm::GetTpDcs");
   664     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSM_GETTPDCS_1,  "CSAT::CSatNotifySendSm::GetTpDcs");
   679     TUint8 retValue( NULL );
   665     TUint8 retValue( NULL );
   680     if ( KSATSmsMTISubmitOrSubmitReport == ( aTpdu[0] & KMask3 ) )
   666     if ( KSATSmsMTISubmitOrSubmitReport == ( aTpdu[0] & KMask3 ) )
   681         {
   667         {
   682         // SMS-SUBMIT
   668         // SMS-SUBMIT
   683         TUint8 posDCS( 0 );
   669         TUint8 posDCS( 0 );
   709 	    (
   695 	    (
   710 	    TPtrC8 aTpdu,   
   696 	    TPtrC8 aTpdu,   
   711 	    TTpdu& aSendSm  
   697 	    TTpdu& aSendSm  
   712 	    )
   698 	    )
   713     {
   699     {
   714     TFLOGSTRING( "CSAT::CSatNotifySendSm::PackSms");
   700     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSM_PACKSMS_1,  "CSAT::CSatNotifySendSm::PackSms");
   715     // See 3GPP TS 23.040 and TS 23.038: 
   701     // See 3GPP TS 23.040 and TS 23.038: 
   716     // Packing of Basic elements of the SMS SUBMIT type
   702     // Packing of Basic elements of the SMS SUBMIT type
   717     TInt ret( KErrNone );
   703     TInt ret( KErrNone );
   718     
   704     
   719     // Message is a SMS-SUBMIT message
   705     // Message is a SMS-SUBMIT message
   795             static_cast<TUint8>( ( aTpdu[startPos + 1] * 8 / 7 ) 
   781             static_cast<TUint8>( ( aTpdu[startPos + 1] * 8 / 7 ) 
   796                 + ( aTpdu[startPos] - aTpdu[startPos + 1] ) );
   782                 + ( aTpdu[startPos] - aTpdu[startPos + 1] ) );
   797             }
   783             }
   798         else
   784         else
   799             {
   785             {
   800             TFLOGSTRING( "CSAT::CSatNotifySendSm::PackSms, No headers");
   786             OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSM_PACKSMS_2,  "CSAT::CSatNotifySendSm::PackSms, No headers");
   801             // No headers, lets pack all the characters in SMS message
   787             // No headers, lets pack all the characters in SMS message
   802             TBool endOfTPDU( EFalse );
   788             TBool endOfTPDU( EFalse );
   803             TUint8 move( 0 );
   789             TUint8 move( 0 );
   804 
   790 
   805             for ( i = startPos; i < aTpdu[startPos] + startPos; i++ )
   791             for ( i = startPos; i < aTpdu[startPos] + startPos; i++ )
   841                         move++;
   827                         move++;
   842                         }
   828                         }
   843                     }
   829                     }
   844                 else
   830                 else
   845                     {
   831                     {
   846                     TFLOGSTRING( "CSAT::CSatNotifySendSm::PackSms, Corrupted");
   832                     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSM_PACKSMS_3,  "CSAT::CSatNotifySendSm::PackSms, Corrupted");
   847                     ret = KErrCorrupt;
   833                     ret = KErrCorrupt;
   848                     break;
   834                     break;
   849                     }    
   835                     }    
   850                 }
   836                 }
   851             }
   837             }