telephonyserverplugins/simatktsy/src/CSatNotifyMoSmControlRequest.cpp
changeset 0 3553901f7fa8
child 24 6638e7f4bd8f
child 42 3adadc800673
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Name        : CSatNotifyMoSmControlRequest.cpp
       
    15 // Part of     : Common SIM ATK TSY / commonsimatktsy
       
    16 // Display text notification functionality of Sat Tsy
       
    17 // Version     : 1.0
       
    18 //
       
    19 
       
    20 
       
    21 
       
    22 //INCLUDES
       
    23 #include <satcs.h>                  // Etel SAT IPC definitions
       
    24 #include "CSatTsy.h"                // Tsy class header
       
    25 #include "CSatNotifyMoSmControlRequest.h"  // Class header
       
    26 #include "CSatNotificationsTsy.h"   // Tsy class header
       
    27 #include "CBerTlv.h"                // Ber Tlv data handling
       
    28 #include "BerTlv_defs.h"            // Ber Tlv specific definitions
       
    29 #include "TTlv.h"					// TTlv class
       
    30 #include "CSatDataPackage.h"        // Parameter packing 
       
    31 #include "TfLogger.h"               // For TFLOGSTRING
       
    32 #include "TSatUtility.h"            // Utilities
       
    33 #include "CSatTsyReqHandleStore.h"  // Request handle class
       
    34 #include "cmmmessagemanagerbase.h" 	// Message manager class for forwarding req.
       
    35 #include "MSatTsy_IPCDefs.h"        // Sat Tsy internal request types
       
    36 
       
    37 // -----------------------------------------------------------------------------
       
    38 // CSatNotifyMoSmControlRequest::NewL
       
    39 // Two-phased constructor.
       
    40 // -----------------------------------------------------------------------------
       
    41 //  
       
    42 CSatNotifyMoSmControlRequest* CSatNotifyMoSmControlRequest::NewL
       
    43         ( 
       
    44         CSatNotificationsTsy* aNotificationsTsy 
       
    45         )
       
    46     {
       
    47     TFLOGSTRING("CSAT: CSatNotifyMoSmControlRequest::NewL");
       
    48    	CSatNotifyMoSmControlRequest* const satNotifyMoSmControlRequest = 
       
    49         new ( ELeave ) CSatNotifyMoSmControlRequest( aNotificationsTsy );
       
    50     CleanupStack::PushL( satNotifyMoSmControlRequest );
       
    51     satNotifyMoSmControlRequest->ConstructL();
       
    52     CleanupStack::Pop( satNotifyMoSmControlRequest );
       
    53     TFLOGSTRING("CSAT: CSatNotifyMoSmControlRequest::NewL, end of method");
       
    54     return satNotifyMoSmControlRequest;
       
    55     }
       
    56 
       
    57 // -----------------------------------------------------------------------------
       
    58 // CSatNotifyMoSmControlRequest::~CSatNotifyMoSmControlRequest
       
    59 // Destructor
       
    60 // -----------------------------------------------------------------------------
       
    61 //  
       
    62 CSatNotifyMoSmControlRequest::~CSatNotifyMoSmControlRequest
       
    63         ( 
       
    64 		// None
       
    65         )
       
    66     {
       
    67     TFLOGSTRING("CSAT: CSatNotifyMoSmControlRequest::\
       
    68     	~CSatNotifyMoSmControlRequest");
       
    69     }
       
    70     
       
    71 // -----------------------------------------------------------------------------
       
    72 // CSatNotifyMoSmControlRequest::CSatNotifyMoSmControlRequest
       
    73 // Default C++ constructor
       
    74 // -----------------------------------------------------------------------------
       
    75 //  
       
    76 CSatNotifyMoSmControlRequest::CSatNotifyMoSmControlRequest
       
    77         ( 
       
    78         CSatNotificationsTsy* aNotificationsTsy 
       
    79         ) : iNotificationsTsy ( aNotificationsTsy )
       
    80     {
       
    81     // None
       
    82     }
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // CSatNotifyMoSmControlRequest::ConstructL
       
    86 // Symbian 2nd phase constructor
       
    87 // -----------------------------------------------------------------------------
       
    88 //  
       
    89 void CSatNotifyMoSmControlRequest::ConstructL
       
    90         (
       
    91         // None
       
    92         )
       
    93     {
       
    94     TFLOGSTRING("CSAT: CSatNotifyMoSmControlRequest::ConstructL");
       
    95     // Checks if MO-SMS control should be activated
       
    96     iNotificationsTsy->iSatTsy->MessageManager()->HandleRequestL( 
       
    97     		ESatTsyMoSmsControlActivation );	
       
    98     // Initialize MO-SMS Control to deactivated
       
    99     iIsMoSmsCtrlActivated = EFalse; 
       
   100     TFLOGSTRING("CSAT: CSatNotifyMoSmControlRequest::ConstructL, \
       
   101     	end of method"); 	
       
   102     }
       
   103 
       
   104 // -----------------------------------------------------------------------------
       
   105 // CSatNotifyMoSmControlRequest::Notify
       
   106 // This request allows a client to be notified of a MO-SMS Control proactive 
       
   107 // command
       
   108 // -----------------------------------------------------------------------------
       
   109 //
       
   110 TInt CSatNotifyMoSmControlRequest::Notify
       
   111         (
       
   112         const TTsyReqHandle aTsyReqHandle,
       
   113         const TDataPackage& aPackage 
       
   114         )
       
   115     {
       
   116     TFLOGSTRING("CSAT: CSatNotifyMoSmControlRequest::Notify");
       
   117 
       
   118     // Save data pointer to client side for completion      
       
   119     iMoSmControlV1Pckg = reinterpret_cast<RSat::TMoSmControlV1Pckg*>(
       
   120     	aPackage.Des1n() );
       
   121     
       
   122     // Save the request handle
       
   123     iNotificationsTsy->iSatTsy->SaveReqHandle( aTsyReqHandle, 
       
   124 		CSatTsy::ESatNotifyMoSmControlRequestPCmdReqType );  
       
   125 
       
   126     return KErrNone;
       
   127     }
       
   128 
       
   129 // -----------------------------------------------------------------------------
       
   130 // CSatNotifyMoSmControlRequest::CancelNotification
       
   131 // This method cancels an outstanding asynchronous 
       
   132 // MoSmControl request.
       
   133 // -----------------------------------------------------------------------------
       
   134 //
       
   135 TInt CSatNotifyMoSmControlRequest::CancelNotification
       
   136         (
       
   137         const TTsyReqHandle aTsyReqHandle
       
   138         )
       
   139     {
       
   140     TFLOGSTRING("CSAT: CSatNotifyMoSmControlRequest::CancelNotification");
       
   141     
       
   142     // Reset the request handle
       
   143     TTsyReqHandle reqHandle = iNotificationsTsy->iSatReqHandleStore->
       
   144         ResetTsyReqHandle( CSatTsy::ESatNotifyMoSmControlRequestPCmdReqType );
       
   145 	// Reset the data pointer
       
   146 	iMoSmControlV1Pckg = NULL;
       
   147 	// Complete the request with KErrCancel
       
   148 	iNotificationsTsy->iSatTsy->ReqCompleted( aTsyReqHandle, KErrCancel );
       
   149 
       
   150     return KErrNone;    
       
   151     }
       
   152 
       
   153 // -----------------------------------------------------------------------------
       
   154 // CSatNotifyMoSmControlRequest::CompleteNotifyL
       
   155 // This method completes an outstanding asynchronous NotifyMoSmControlRequest
       
   156 // request. 
       
   157 // -----------------------------------------------------------------------------
       
   158 //
       
   159 TInt CSatNotifyMoSmControlRequest::CompleteNotifyL
       
   160         (
       
   161         CSatDataPackage* aDataPackage,   
       
   162         TInt aErrorCode                
       
   163         )
       
   164     {
       
   165     TFLOGSTRING("CSAT: CSatNotifyMoSmControlRequest::CompleteNotifyL" );
       
   166     
       
   167     CSatNotificationsTsy::TMoSmCtrlData moSmCtrlData;
       
   168 
       
   169     // Initialize parameters
       
   170     moSmCtrlData.iResult = KMoSmCtrlResultAllowed;
       
   171     moSmCtrlData.iAlphaId = NULL;
       
   172     
       
   173     // The request is completed to the client only if Alpha ID is present,
       
   174     // otherwise just handle the message just internally
       
   175     if ( KErrNone == aErrorCode )
       
   176     	{ 	
       
   177     	TBuf8<KAddrMaxLength> addr1;
       
   178         TBuf8<KAddrMaxLength> addr2;
       
   179         RSat::TAlphaId alphaId;
       
   180         alphaId.iAlphaId.Zero();
       
   181         alphaId.iStatus = RSat::EAlphaIdNotPresent;
       
   182         TBool simRespDataConsistent( ETrue );        
       
   183     	TBool isDataOk( ETrue );
       
   184     	
       
   185     	// Unpack parameters
       
   186 		TDesC8* atkData = NULL;
       
   187 		aDataPackage->UnPackData( &atkData );
       
   188     	
       
   189     	TFLOGSTRING2("CSAT: CSatNotifyMoSmControlRequest::CompleteNotifyL\
       
   190     	    Data length: %d", ( *atkData ).Length() );
       
   191     	
       
   192 	    if ( KTlvMaxSize < ( *atkData ).Length() )
       
   193 	    	{
       
   194             TFLOGSTRING("CSAT: CSatNotifyMoSmControlRequest::CompleteNotifyL, \
       
   195                 Data length exceeded" );                
       
   196             // Data not consistent, reject the call
       
   197             moSmCtrlData.iResult = KMoSmCtrlResultNotAllowed;
       
   198 	        isDataOk = EFalse;
       
   199             }
       
   200         else if ( ( *atkData ).Length() )
       
   201             {
       
   202             // Note: The alpha id can be provided by the NAA even if the addresses
       
   203             // have not been modified.                
       
   204             ParseNotification( *atkData, addr1, addr2, alphaId  ); 
       
   205 
       
   206             if ( KMoSmCtrlResultAllowedWithModifications == ( *atkData )[0] )
       
   207                 {
       
   208                 TFLOGSTRING3("CSAT: CSatNotifyMoSmControlRequest::CompleteNotifyL\
       
   209     	            Addr1: %s, Addr2: %s", &addr1, &addr2 );
       
   210                 simRespDataConsistent = VerifyNotificationData( addr1, addr2 );      
       
   211                 }
       
   212                 
       
   213             if ( simRespDataConsistent )
       
   214                 {
       
   215             	// atkData[0] --> result
       
   216             	moSmCtrlData.iResult = ( *atkData )[0];            
       
   217                 }
       
   218             else
       
   219                 {
       
   220                 TFLOGSTRING("CSAT: CSatNotifyMoSmControlRequest::CompleteNotifyL, \
       
   221                 	NAA response data not consistent" );                
       
   222                 // Data not consistent, reject the sms
       
   223                 moSmCtrlData.iResult = KMoSmCtrlResultNotAllowed;
       
   224 	        	isDataOk = EFalse;
       
   225                 }
       
   226             }
       
   227              
       
   228         // Prepare rest of the data for response        
       
   229         moSmCtrlData.iAddressData.iRPDestinationAddr.Set( addr1 );
       
   230         moSmCtrlData.iAddressData.iTPDestinationAddr.Set( addr2 );
       
   231         moSmCtrlData.iAlphaId = &alphaId;
       
   232         
       
   233         // Pack data and send response to NAA
       
   234     	CSatDataPackage dataPackage;
       
   235     	dataPackage.PackData( &moSmCtrlData );
       
   236         iNotificationsTsy->iSatTsy->MessageManager()->HandleRequestL( 
       
   237         	ESatNotifyMoSmControlRequest, &dataPackage );
       
   238 	    
       
   239 	    // Then start checking whether the client nees to be notified as well..
       
   240 	    // Check if the MO-SMS is activated and the data is verified ok
       
   241 	    if ( iIsMoSmsCtrlActivated && isDataOk )
       
   242 	        {          
       
   243 		    // Get req handle. Can not be deleted yet, since completion
       
   244 		    // depends on the presence of Alpha ID
       
   245 		    TTsyReqHandle reqHandle = 
       
   246 		        iNotificationsTsy->iSatReqHandleStore->TsyReqHandle( 
       
   247 		            CSatTsy::ESatNotifyMoSmControlRequestPCmdReqType );
       
   248 		    
       
   249 		    // In case the request was ongoing, continue.. But note that
       
   250 		    // the client is notified only if AlphaID is present, in order 
       
   251 		    // to inform that the ETel API MO-SMS Control structure 
       
   252 		    // TMoSmControlV1 has been modified.
       
   253 	        if ( CSatTsy::ESatReqHandleUnknown != reqHandle &&
       
   254 	             ( moSmCtrlData.iAlphaId->iAlphaId.Length() || 
       
   255 	             RSat::EAlphaIdNull == moSmCtrlData.iAlphaId->iStatus ) )
       
   256 	            {
       
   257 	            // Now its safe to reset the request handle
       
   258 		        iNotificationsTsy->iSatReqHandleStore->ResetTsyReqHandle( 
       
   259 		            CSatTsy::ESatNotifyMoSmControlRequestPCmdReqType );
       
   260 	            // Fill the call control structure
       
   261 		        RSat::TMoSmControlV1& moSmControlV1 = 
       
   262 		        	( *iMoSmControlV1Pckg )();
       
   263 		        
       
   264 	            // Control result must be mapped to ETel API values.
       
   265 	            switch ( ( *atkData )[0] )
       
   266 	                {
       
   267 	                case KMoSmCtrlResultAllowed:
       
   268 	                    {
       
   269 	                    moSmControlV1.iResult = 
       
   270 	                    	RSat::EAllowedNoModification;
       
   271 	                    break;
       
   272 	                    }
       
   273 	                case KMoSmCtrlResultAllowedWithModifications:
       
   274 	                    {
       
   275 	                    moSmControlV1.iResult = 
       
   276 	                    	RSat::EAllowedWithModifications;
       
   277 	                    break;
       
   278 	                    }
       
   279 	                case KMoSmCtrlResultNotAllowed:
       
   280 	                    {
       
   281 	                    moSmControlV1.iResult = RSat::ENotAllowed;
       
   282 	                    break;
       
   283 	                    }
       
   284 	                default:
       
   285 	                    {
       
   286 	                    moSmControlV1.iResult = RSat::EControlResultNotSet;
       
   287 	                    break;
       
   288 	                    }
       
   289 	                }
       
   290 
       
   291 		        // Set alpha id and status
       
   292 		        moSmControlV1.iAlphaId.iAlphaId.Append( alphaId.iAlphaId );
       
   293 		        moSmControlV1.iAlphaId.iStatus = alphaId.iStatus;
       
   294 		        
       
   295 		        // Complete notification to the client
       
   296 	    		iNotificationsTsy->iSatTsy->ReqCompleted( reqHandle, 
       
   297 	    		    KErrNone );
       
   298 	            } // If Alpha ID or request handle
       
   299 
       
   300 	        } // If MO SM Ctrl Activated and data ok
       
   301 	    else
       
   302 	        {
       
   303 	        TFLOGSTRING3("LSAT: CSatMoSmsCtrlMessHandler::CompleteNotifyL, \
       
   304     	        iIsMoSmsCtrlActivated: %d, isDataOk: %d ", 
       
   305     	        iIsMoSmsCtrlActivated, isDataOk);
       
   306 	        }
       
   307     	} // if KErrNone
       
   308     else
       
   309         {
       
   310         TFLOGSTRING("LSAT: CSatMoSmsCtrlMessHandler::CompleteNotifyL, \
       
   311         	Error in notification ");
       
   312         moSmCtrlData.iResult = KMoSmCtrlResultNotAllowed;
       
   313         // Pack data and send response right away to NAA
       
   314     	CSatDataPackage dataPackage;
       
   315     	dataPackage.PackData( &moSmCtrlData );
       
   316         iNotificationsTsy->iSatTsy->MessageManager()->HandleRequestL( 
       
   317         	ESatNotifyMoSmControlRequest, &dataPackage );
       
   318         }
       
   319 
       
   320     return KErrNone;
       
   321     }
       
   322      
       
   323 // -----------------------------------------------------------------------------
       
   324 // CSatNotifyMoSmControlRequest::CreateMoSmsCtrlEnvelopeL
       
   325 // Send an envelope to SIM server in order to check wheter the SMS can be sent 
       
   326 // or not. The response will be used to send a response to SMS server
       
   327 // -----------------------------------------------------------------------------
       
   328 //
       
   329 void CSatNotifyMoSmControlRequest::CreateMoSmsCtrlEnvelopeL
       
   330 	    (
       
   331 	    CSatDataPackage* aDataPackage,
       
   332 	    TInt /*aResult*/
       
   333 	    )   
       
   334     {   
       
   335     TFLOGSTRING("CSAT: CSatNotifyMoSmControlRequest::\
       
   336         CreateMoSmsCtrlEnvelopeL"); 
       
   337     // Check first if the MO-SMS is activated
       
   338     if ( iIsMoSmsCtrlActivated )
       
   339         {  
       
   340     	TFLOGSTRING("CSAT: CSatNotifyMoSmControlRequest::\
       
   341     		CreateMoSmsCtrlEnvelopeL, MO SM Ctrl Activated");
       
   342     	
       
   343 	    CSatNotificationsTsy::TAddressData* addressData;
       
   344 	    
       
   345 	    // Unpack data
       
   346 	    aDataPackage->UnPackData( &addressData );
       
   347 	    
       
   348 	    TTlv envelope;
       
   349 
       
   350 	    envelope.Begin( KBerTlvMoShortMessageControlTag );
       
   351 	    //device identities
       
   352 	    envelope.AddTag( KTlvDeviceIdentityTag );
       
   353 	    envelope.AddByte( KMe );
       
   354 	    envelope.AddByte( KSim );
       
   355 	    // Address Data object 1
       
   356 	    // Ton and Npi is in the first byte of address data
       
   357 	    envelope.AddTag( KTlvAddressTag );
       
   358 	    envelope.AddData( addressData->iRPDestinationAddr );
       
   359 	    // Address Data object 2
       
   360 	    // Ton and Npi is in the first byte of address data
       
   361 	    envelope.AddTag( KTlvAddressTag );
       
   362 	    envelope.AddData( addressData->iTPDestinationAddr );
       
   363 
       
   364 	    // !!! This part assumes that location info has been received
       
   365 	    // Mobile Country & Network Codes (MCC & MNC)
       
   366 	    iNotificationsTsy->AddLocationInformationToTlv( envelope );
       
   367 	        	
       
   368 	   	// Prepare data
       
   369 	    TPtrC8 data = envelope.End();
       
   370 	    // Pack data
       
   371 	    CSatDataPackage dataPackage;
       
   372 	    dataPackage.PackData( &data );
       
   373 	    
       
   374 	    // Forward request to the DOS. Send envelope only if its length is less 
       
   375 	    // than the maximum allowed envelope length.
       
   376 	    iNotificationsTsy->iSatTsy->MessageManager()->HandleRequestL( 
       
   377 	        ESatTsySendEnvelope, &dataPackage );
       
   378         }
       
   379     }
       
   380     
       
   381 // -----------------------------------------------------------------------------
       
   382 // CSatNotifyMoSmControlRequest::Activate
       
   383 // Set iIsMoSmsCtrlActivated to ETrue if MO-SMS Control has to be activated
       
   384 // -----------------------------------------------------------------------------
       
   385 //
       
   386 void CSatNotifyMoSmControlRequest::SetActivationStatus
       
   387 		(
       
   388 		CSatDataPackage* aDataPackage
       
   389 		)
       
   390     {
       
   391     // Unpack data
       
   392     aDataPackage->UnPackData( iIsMoSmsCtrlActivated );
       
   393     TFLOGSTRING2("CSAT: CSatNotifyMoSmControlRequest::SetActivationStatus, %d",
       
   394     	iIsMoSmsCtrlActivated );
       
   395     }
       
   396 
       
   397 // -----------------------------------------------------------------------------
       
   398 // CSatNotifyMoSmControlRequest::ActivationStatus
       
   399 // Returns ETrue if MO-SMS Control is activated
       
   400 // -----------------------------------------------------------------------------
       
   401 //
       
   402 TBool CSatNotifyMoSmControlRequest::ActivationStatus
       
   403 		(
       
   404 		void
       
   405 		)
       
   406     {
       
   407     TFLOGSTRING("CSAT: CSatNotifyMoSmControlRequest::ActivationStatus");
       
   408     return iIsMoSmsCtrlActivated;
       
   409     }
       
   410     
       
   411 // -----------------------------------------------------------------------------
       
   412 // CSatNotifyMoSmControlRequest::CleanAddressData
       
   413 // This method cleans the input address data, so that all the bytes found
       
   414 // after a 0xXF or a 0xFX are removed.
       
   415 // -----------------------------------------------------------------------------
       
   416 //
       
   417 void CSatNotifyMoSmControlRequest::CleanAddressData
       
   418 		( 
       
   419 		TDes8& aAddr 
       
   420 		)
       
   421     {
       
   422     TFLOGSTRING("CSAT: CSatNotifyMoSmControlRequest::CleanAddressData");
       
   423     // Starts from index 1, since index 0 is for TON/NPI    
       
   424     for ( TInt i=1; i < aAddr.Length(); i++ )
       
   425         {
       
   426         if ( 0xF0 == ( aAddr[i] & 0xF0 ) )
       
   427             {
       
   428             if ( ( i + 1 ) < aAddr.Length() )
       
   429                 {
       
   430                 aAddr.Delete( i + 1, aAddr.Length() - i - 1 );
       
   431                 }
       
   432             break;
       
   433             }
       
   434         else if ( 0x0F == ( aAddr[i] & 0x0F ) )
       
   435             {
       
   436             aAddr.Delete( i, aAddr.Length() - i );
       
   437             break;
       
   438             }        
       
   439         }
       
   440     }
       
   441     
       
   442 // -----------------------------------------------------------------------------
       
   443 // CSatNotifyMoSmControlRequest::ParseNotification
       
   444 // Extracts data from proactive command data
       
   445 // -----------------------------------------------------------------------------
       
   446 //
       
   447 void CSatNotifyMoSmControlRequest::ParseNotification
       
   448 		(
       
   449 	    const TDesC8& aAtkData,
       
   450 	    TDes8& aAddr1,
       
   451 	    TDes8& aAddr2,
       
   452 	    RSat::TAlphaId& aAlphaId
       
   453 	    )
       
   454     {
       
   455     TFLOGSTRING("CSAT: CSatNotifyMoSmControlRequest::ParseNotification");
       
   456     
       
   457     // Input data:
       
   458     // aAtkData[0] : result
       
   459     // aAtkData[1][2] : length of BER-TLV, set n=1 if aAtkData[1]=0x81
       
   460     // aAtkData[2+n] : tag of first TLV
       
   461     // aAtkData[3+n][4+n] : length of first TLV, set nn=1 if aAtkData[3+n]=0x81
       
   462     // etc..
       
   463     
       
   464     // Comments drawn from SAT TS lab test cases:
       
   465     // - The NAA may insert a wild '0xD' character in addresses and therefore 
       
   466     // the phone sw should prevent the sending of the SMS. At the time this 
       
   467     // comment is being written, it is not clear which part prevents it, if 
       
   468     // prevents ? And this is not yet handled in SIM ATK TSY.
       
   469     // - The NAA may insert a 0xF in addresses, and the phone sw should discard
       
   470     // all characters placed after the 0xF. At the time when this
       
   471     // comment is being written, it is not clear which part should do that,
       
   472     // and this is not yet handled in SIM ATK TSY.
       
   473     
       
   474     // Check if the BER-TLV length is coded with 2 bytes.
       
   475     TInt indexInBerTlv( 1 );
       
   476     TUint8 tag( aAtkData[indexInBerTlv] );
       
   477     TUint8 lengthBerTlv( 0 );
       
   478     TInt n( ( KTwoByteLengthCoding == tag ) ? 1:0 );    
       
   479     lengthBerTlv = aAtkData[1 + n];
       
   480     indexInBerTlv = 2 + n;
       
   481     
       
   482     // Initialize Alpha ID
       
   483     aAlphaId.iAlphaId.Zero();
       
   484     
       
   485     // Extract TLVs and fill in output variables
       
   486     TBool address1_got( EFalse );
       
   487     while( lengthBerTlv )
       
   488         {
       
   489         // Get tag value without 'comprehension required' bit
       
   490         tag = aAtkData[indexInBerTlv] & 0x7F;
       
   491         // Length of TLV with 2 bytes ?
       
   492         TInt nn( ( KTwoByteLengthCoding == aAtkData[indexInBerTlv +1 ] )?1:0 );
       
   493         // Length of TLV
       
   494         TInt lengthTlv( aAtkData[indexInBerTlv + nn + 1] );
       
   495         
       
   496         // Check which TLV is received
       
   497         if ( ( KTlvAddressTag == tag ) && ( !address1_got ) )
       
   498             {
       
   499             TFLOGSTRING("CSAT: CSatNotifyMoSmControlRequest::ParseNotification\
       
   500                 Address 1");
       
   501             // RP address first
       
   502             address1_got = ETrue;
       
   503             // Copy data to output variable
       
   504             aAddr1.Copy( aAtkData.Mid( indexInBerTlv + nn + 2, lengthTlv ) );
       
   505             if ( KReservedTonNpi1 != aAddr1[0] && 
       
   506             	 KReservedTonNpi2 != aAddr1[0] && ( 1 < lengthTlv ) )
       
   507                 {
       
   508                 CleanAddressData( aAddr1 );
       
   509                 }            
       
   510             }
       
   511         else if ( KTlvAddressTag == tag )
       
   512             {
       
   513             TFLOGSTRING("CSAT: CSatNotifyMoSmControlRequest::ParseNotification\
       
   514                 Address 2");
       
   515             // TP address. Copy data to output variable
       
   516             aAddr2.Copy( aAtkData.Mid( indexInBerTlv + nn + 2, lengthTlv ) );         
       
   517             if ( KReservedTonNpi1 != aAddr2[0] && 
       
   518             	 KReservedTonNpi2 != aAddr2[0] && ( 1 < lengthTlv ) )
       
   519                 {
       
   520                 CleanAddressData( aAddr2 );
       
   521                 }    
       
   522             }
       
   523         else if ( KTlvAlphaIdentifierTag == tag )
       
   524             {
       
   525             TFLOGSTRING("CSAT: CSatNotifyMoSmControlRequest::ParseNotification\
       
   526                 Alpha ID");
       
   527             // Alpha id must be converted to TBuf16/unicode
       
   528             if ( lengthTlv )
       
   529                 {
       
   530                 // Set Alpha id status
       
   531 			        aAlphaId.iStatus = RSat::EAlphaIdProvided;
       
   532                 TSatUtility::SetAlphaId( aAtkData.Mid( indexInBerTlv + nn + 2, 
       
   533                     lengthTlv ), aAlphaId.iAlphaId );                                
       
   534                 }
       
   535             else
       
   536                 {
       
   537                 TFLOGSTRING("CSAT: CSatNotifyMoSmControlRequest:: \
       
   538                 	ParseNotification. Alpha ID is NULL");
       
   539                 aAlphaId.iStatus = RSat::EAlphaIdNull;
       
   540                 }  
       
   541             }
       
   542  
       
   543         // Update length for the while loop    
       
   544         lengthBerTlv -= ( lengthTlv + 2 + nn );
       
   545         // Updata index for the while loop
       
   546         indexInBerTlv += ( lengthTlv + 2 + nn );
       
   547         }    
       
   548     }
       
   549     
       
   550 // -----------------------------------------------------------------------------
       
   551 // CSatNotifyMoSmControlRequest::VerifyNotificationData
       
   552 // This method checks the consistency of the data sent by the NAA to the ME, 
       
   553 // when the call is allowed and modified.
       
   554 // -----------------------------------------------------------------------------
       
   555 //
       
   556 TBool CSatNotifyMoSmControlRequest::VerifyNotificationData
       
   557 		( 
       
   558 		TDes8& aRPAddr, 
       
   559 		TDes8& aTPAddr 
       
   560 		)
       
   561     {
       
   562     TFLOGSTRING("CSAT: CSatNotifyMoSmControlRequest::VerifyNotificationData");
       
   563     TBool ret( ETrue );    
       
   564     if ( ( 0 == aRPAddr.Length() && 0 == aTPAddr.Length() ) || 
       
   565          ( KMoSmCtrlMaxLengthAddr1Addr2 <= ( 
       
   566          	aRPAddr.Length() + aTPAddr.Length() ) ) ) 
       
   567         {
       
   568         ret = EFalse;
       
   569         }
       
   570     else
       
   571         {
       
   572         // Detect the presence of 'wild' values in the digits of the addresses       
       
   573         for ( TInt i = 0; i < aRPAddr.Length(); i++)
       
   574             {
       
   575             if ( ( 0x0A < ( 0x0F & aRPAddr[i] ) && 
       
   576                    0x0F > ( 0x0F & aRPAddr[i] ) ) ||
       
   577                  ( 0xA0 < ( 0xF0 & aRPAddr[i] ) && 
       
   578                    0xF0 > ( 0xF0 & aRPAddr[i] ) ) )
       
   579                 {
       
   580                 ret = EFalse;
       
   581                 break;
       
   582                 }            
       
   583             }
       
   584         for ( TInt i = 0; i < aTPAddr.Length(); i++)
       
   585             {
       
   586             if ( ( 0x09 < ( 0x0F & aTPAddr[i] ) && 
       
   587                    0x0F > ( 0x0F & aTPAddr[i] ) ) ||
       
   588                  ( 0x90 < ( 0xF0 & aTPAddr[i] ) && 
       
   589                    0xF0 > ( 0xF0 & aTPAddr[i] ) ) )
       
   590                 {
       
   591                 ret = EFalse;
       
   592                 break;
       
   593                 }            
       
   594             }        
       
   595         }    
       
   596     return ret;
       
   597     }
       
   598     
       
   599 // End of File
       
   600