telephonyserverplugins/simatktsy/src/CSatNotifyRefresh.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        : CSatNotifyRefresh.cpp
       
    15 // Part of     : Common SIM ATK TSY / commonsimatktsy
       
    16 // Refresh 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 "CSatNotifyRefresh.h"  	// Class header
       
    26 #include "CSatNotificationsTsy.h"   // Tsy class header
       
    27 #include "CBerTlv.h"                // Ber Tlv data handling
       
    28 #include "TTlv.h"					// TTlv class
       
    29 #include "CSatDataPackage.h"        // Parameter packing 
       
    30 #include "TfLogger.h"               // For TFLOGSTRING
       
    31 #include "TSatUtility.h"            // Utilities
       
    32 #include "CSatTsyReqHandleStore.h"  // Request handle class
       
    33 #include "cmmmessagemanagerbase.h"  // Message manager class for forwarding req.
       
    34 //#include "CMmCustomTsy.h"           // Custom Tsy class
       
    35 #include "MSatTsy_IPCDefs.h"        // Sat Tsy internal request types
       
    36 
       
    37 
       
    38 // -----------------------------------------------------------------------------
       
    39 // CSatNotifyRefresh::NewL
       
    40 // Two-phased constructor.
       
    41 // -----------------------------------------------------------------------------
       
    42 //  
       
    43 CSatNotifyRefresh* CSatNotifyRefresh::NewL
       
    44         ( 
       
    45         CSatNotificationsTsy* aNotificationsTsy 
       
    46         )
       
    47     {
       
    48     TFLOGSTRING("CSAT: CSatNotifyRefresh::NewL");
       
    49    	CSatNotifyRefresh* const satNotifyRefresh = 
       
    50         new ( ELeave ) CSatNotifyRefresh( aNotificationsTsy );
       
    51     CleanupStack::PushL( satNotifyRefresh );
       
    52     satNotifyRefresh->ConstructL();
       
    53     CleanupStack::Pop( satNotifyRefresh );
       
    54     TFLOGSTRING("CSAT: CSatNotifyRefresh::NewL, end of method");
       
    55     return satNotifyRefresh;
       
    56     }
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 // CSatNotifyRefresh::~CSatNotifyRefresh
       
    60 // Destructor
       
    61 // -----------------------------------------------------------------------------
       
    62 //  
       
    63 CSatNotifyRefresh::~CSatNotifyRefresh
       
    64         ( 
       
    65 		// None
       
    66         )
       
    67     {
       
    68     TFLOGSTRING("CSAT: CSatNotifyRefresh::~CSatNotifyRefresh");
       
    69     }
       
    70     
       
    71 // -----------------------------------------------------------------------------
       
    72 // CSatNotifyRefresh::CSatNotifyRefresh
       
    73 // Default C++ constructor
       
    74 // -----------------------------------------------------------------------------
       
    75 //  
       
    76 CSatNotifyRefresh::CSatNotifyRefresh
       
    77         ( 
       
    78         CSatNotificationsTsy* aNotificationsTsy 
       
    79         ) : iNotificationsTsy ( aNotificationsTsy )
       
    80     {
       
    81     // None
       
    82     }
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // CSatNotifyRefresh::ConstructL
       
    86 // Symbian 2nd phase constructor
       
    87 // -----------------------------------------------------------------------------
       
    88 //  
       
    89 void CSatNotifyRefresh::ConstructL
       
    90         (
       
    91         // None
       
    92         )
       
    93     {
       
    94     TFLOGSTRING("CSAT: CSatNotifyRefresh::ConstructL");
       
    95     }
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // CSatNotifyRefresh::Notify
       
    99 // This request allows a client to be notified of a REFRESH proactive command
       
   100 // -----------------------------------------------------------------------------
       
   101 //
       
   102 TInt CSatNotifyRefresh::Notify
       
   103         (
       
   104         const TTsyReqHandle aTsyReqHandle,
       
   105         const TDataPackage& aPackage  
       
   106         )
       
   107     {
       
   108     TFLOGSTRING("CSAT: CSatNotifyRefresh::Notify");
       
   109 
       
   110     // Save data pointer to client side for completion
       
   111     iRefreshV2Pckg = reinterpret_cast<RSat::TRefreshV2Pckg*>( 
       
   112         aPackage.Des1n() );
       
   113     
       
   114     // Save the request handle
       
   115     iNotificationsTsy->iSatTsy->SaveReqHandle( aTsyReqHandle, 
       
   116 		CSatTsy::ESatNotifyRefreshPCmdReqType );
       
   117 
       
   118     if ( iNotificationsTsy->iSatReqHandleStore->TsyReqHandle(
       
   119 		CSatTsy::ESatNotifyRefreshRequiredPCmdReqType ) )
       
   120     	{
       
   121     	// Check the command buffer, if both notifications are received
       
   122     	iNotificationsTsy->NotifySatReadyForNotification( KRefresh );   
       
   123     	}
       
   124     return KErrNone;   
       
   125     }
       
   126 
       
   127 // -----------------------------------------------------------------------------
       
   128 // CSatNotifyRefresh::Notify
       
   129 // This request allows a client to be notified of a REFRESH proactive 
       
   130 // command
       
   131 // -----------------------------------------------------------------------------
       
   132 //
       
   133 TInt CSatNotifyRefresh::NotifyRefreshRequired
       
   134         (
       
   135         const TTsyReqHandle aTsyReqHandle,
       
   136         const TDataPackage& aPackage 
       
   137         )
       
   138     {
       
   139     TFLOGSTRING("CSAT: CSatNotifyRefresh::NotifyRefreshRequired");
       
   140 
       
   141     // Save data pointer to client side for completion
       
   142     iRefreshRequiredV2Pckg = reinterpret_cast<RSat::TRefreshV2Pckg*>( 
       
   143         aPackage.Des1n() );
       
   144     
       
   145     // Save the request handle
       
   146     iNotificationsTsy->iSatTsy->SaveReqHandle( aTsyReqHandle, 
       
   147 		CSatTsy::ESatNotifyRefreshRequiredPCmdReqType );
       
   148 	
       
   149 	if ( iNotificationsTsy->iSatReqHandleStore->TsyReqHandle(
       
   150 		CSatTsy::ESatNotifyRefreshPCmdReqType ) )
       
   151 		{
       
   152     	// Check the command buffer, if both notifications are received
       
   153     	iNotificationsTsy->NotifySatReadyForNotification( KRefresh );   
       
   154 		}
       
   155 	return KErrNone;  
       
   156     }
       
   157     
       
   158 // -----------------------------------------------------------------------------
       
   159 // CSatNotifyRefresh::CancelNotification
       
   160 // This method cancels an outstanding asynchronous 
       
   161 // NotifyRefresh request.
       
   162 // -----------------------------------------------------------------------------
       
   163 //
       
   164 TInt CSatNotifyRefresh::CancelNotification
       
   165         (
       
   166         const TTsyReqHandle aTsyReqHandle
       
   167         )
       
   168     {
       
   169     TFLOGSTRING( "CSAT: CSatNotifyRefresh::CancelNotification" );
       
   170     
       
   171     // Reset the request handle
       
   172     iNotificationsTsy->iSatReqHandleStore->ResetTsyReqHandle( 
       
   173         CSatTsy::ESatNotifyRefreshPCmdReqType );
       
   174 
       
   175     // Reset the data pointer
       
   176     iRefreshV2Pckg = NULL;
       
   177 
       
   178     // Complete the request with KErrCancel
       
   179     iNotificationsTsy->iSatTsy->ReqCompleted( aTsyReqHandle, KErrCancel );
       
   180 
       
   181     return KErrNone;    
       
   182     }
       
   183 
       
   184 // -----------------------------------------------------------------------------
       
   185 // CSatNotifyRefresh::CancelRefreshRequiredNotification
       
   186 // Cancels the current notification request set the request handle
       
   187 // -----------------------------------------------------------------------------
       
   188 //    
       
   189 TInt CSatNotifyRefresh::CancelRefreshRequiredNotification
       
   190 		( 
       
   191     	const TTsyReqHandle aTsyReqHandle
       
   192      	)
       
   193 	{
       
   194     TFLOGSTRING( "CSAT: CSatNotifyRefresh::CancelRefreshRequiredNotification" );
       
   195         
       
   196     // Reset the request handle
       
   197     iNotificationsTsy->iSatReqHandleStore->ResetTsyReqHandle( 
       
   198         CSatTsy::ESatNotifyRefreshRequiredPCmdReqType );
       
   199 
       
   200     // Reset the data pointer
       
   201     iRefreshRequiredV2Pckg = NULL;
       
   202 
       
   203     // Complete the request with KErrCancel
       
   204     iNotificationsTsy->iSatTsy->ReqCompleted( aTsyReqHandle, KErrCancel );
       
   205 
       
   206     return KErrNone; 
       
   207     }
       
   208 
       
   209 // -----------------------------------------------------------------------------
       
   210 // CSatNotifyRefresh::CompleteNotifyL
       
   211 // This method completes an outstanding asynchronous 
       
   212 // NotifyRefresh request. 
       
   213 // -----------------------------------------------------------------------------
       
   214 //
       
   215 TInt CSatNotifyRefresh::CompleteNotifyL
       
   216         (
       
   217         CSatDataPackage* aDataPackage,   
       
   218         TInt aErrorCode                 
       
   219         )
       
   220     {
       
   221     TFLOGSTRING("CSAT: CSatNotifyRefresh::CompleteNotifyL");
       
   222 
       
   223     TInt ret( KErrNone );
       
   224 	TBuf<1> additionalInfo;	
       
   225     // Unpack parameters
       
   226     TPtrC8* data;
       
   227     aDataPackage->UnPackData( &data );
       
   228     TFLOGSTRING2("CSAT: CSatNotifyRefresh::CompleteNotifyL, dataLength: %d", 
       
   229         data->Length());
       
   230     // Reset req handle. Returns the deleted req handle
       
   231     TTsyReqHandle reqHandle = iNotificationsTsy->iSatReqHandleStore->
       
   232         TsyReqHandle( CSatTsy::ESatNotifyRefreshPCmdReqType );
       
   233     TTsyReqHandle reqHandleRefreshRequired = iNotificationsTsy->
       
   234     	iSatReqHandleStore->ResetTsyReqHandle( 
       
   235     		CSatTsy::ESatNotifyRefreshRequiredPCmdReqType );
       
   236 		
       
   237     // Get ber tlv 
       
   238     CBerTlv berTlv;
       
   239     berTlv.SetData( *data );
       
   240     // Get command details tlv
       
   241     CTlv commandDetails;
       
   242     berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag );
       
   243     // Store command details tlv
       
   244     iNotificationsTsy->iTerminalRespData.iCommandDetails.Copy( 
       
   245         commandDetails.Data() );
       
   246     // Get command qualifier
       
   247     TUint8 cmdQualifier( commandDetails.GetShortInfo( 
       
   248         ETLV_CommandQualifier ) );
       
   249         
       
   250     TUint8 pCmdNumber( commandDetails.GetShortInfo( ETLV_CommandNumber ) );    
       
   251     
       
   252     // In case the request was ongoing, continue..
       
   253     if ( ( CSatTsy::ESatReqHandleUnknown != reqHandle ) &&
       
   254     	 ( CSatTsy::ESatReqHandleUnknown != reqHandleRefreshRequired ) )
       
   255         {
       
   256         // Complete right away if error has occured, otherwise continue..
       
   257         if ( KErrNone == aErrorCode )
       
   258             {
       
   259 	        // Fill the refresh structure
       
   260 	        RSat::TRefreshV2& refreshV2 = ( *iRefreshV2Pckg )();
       
   261 
       
   262 	        TInt returnValue( KErrNone );
       
   263 	       
       
   264 	        refreshV2.iAid.Zero();
       
   265 	        
       
   266 	         // File list
       
   267 	        refreshV2.iFileList.Zero();
       
   268 	        iFileList.Zero();
       
   269 	        iInternalCache = 0;
       
   270 	        
       
   271 	        // Used in case of SimInit refresh + Imsi change 
       
   272             iImsiState = ENotSet;
       
   273 
       
   274 	        CTlv fileListTlv;
       
   275 	        returnValue = berTlv.TlvByTagValue( &fileListTlv, 
       
   276 	                                            KTlvFileListTag );
       
   277 	        if ( KErrNone == returnValue )
       
   278 	            {
       
   279 	            // Filelist found
       
   280 	            // File list length, -1 for number of files 
       
   281 	            TUint8 fileLength( (TUint8)( fileListTlv.GetLength() - 1 ) );
       
   282 	           
       
   283 	            // Save file list with full path.
       
   284 	            iFileList = fileListTlv.GetData( ETLV_Files );
       
   285 
       
   286 	            // Going through all files
       
   287 	            // Received as 8-bit, append to 16-bit
       
   288 	            TInt i( 0 );
       
   289 
       
   290 	            for ( i = 0; i < fileLength / 2; i++ )
       
   291 	                {                           
       
   292 	                TUint16 oneItem( 0 );
       
   293 	                // Read 16-bit
       
   294 	                TSatUtility::CopyTwo8toOne16LE( iFileList, oneItem, 2 * i );
       
   295 	                // File header 8-bit
       
   296 	                TUint8 header( TUint8( oneItem >> 8 ) );
       
   297 
       
   298 	                // The TSY needs to strip the Refresh File List 
       
   299 	                // provided by the ICC to remove the paths to the files.
       
   300 	                // '3FXX': Master File;
       
   301 	                // '7FXX': 1st level Dedicated File;
       
   302 	                // '5FXX': 2nd level Dedicated File;
       
   303 	                if ( ( KRefreshMasterFileHeader != header )
       
   304 	                    && ( KRefresh1StLevelDedicatedFileHeader != header ) 
       
   305 	                    && ( KRefresh2StLevelDedicatedFileHeader != header ) )
       
   306 	                    {
       
   307 	                    // Append file to the file list, without path
       
   308 	                    refreshV2.iFileList.Append( oneItem );
       
   309 	                    }
       
   310 	                }
       
   311 	            // Check if the file list contains the EF-SST file which is cached 
       
   312 	            // in COMMON SIM ATK TSY
       
   313 	            if ( KErrNotFound != refreshV2.iFileList.Locate( RSat::KSstEf ) )   
       
   314 	                {
       
   315 	                iInternalCache |= CSatNotificationsTsy::ECacheEFSST;
       
   316 	                }
       
   317 	            // Check EF-CBMID
       
   318 	            if ( KErrNotFound != refreshV2.iFileList.Locate( RSat::KCbmidEf ) )   
       
   319 	                {
       
   320 	                iInternalCache |= CSatNotificationsTsy::ECacheEFCBMID;
       
   321 	                }
       
   322 	            }
       
   323 	        else if ( KFileChangeNotification == iNotificationsTsy->
       
   324 	        	iTerminalRespData.iCommandDetails[KCommandQualifier] )
       
   325 	            {
       
   326 	            TFLOGSTRING("CSAT: CSatNotifyRefresh::CompleteNotifyL,\
       
   327 	                File list missing");
       
   328 	            // File list object is missing, return terminal resp immediately.
       
   329 	            ret = KErrCorrupt;
       
   330 	            additionalInfo.Zero();
       
   331 	            additionalInfo.Append( RSat::KNoSpecificMeProblem ); 
       
   332 	            CreateTerminalRespL( pCmdNumber, 
       
   333 	                RSat::KErrorRequiredValuesMissing, additionalInfo );                                                                
       
   334 	            }
       
   335 	        if ( KErrNone == ret )
       
   336 	            {
       
   337 	            // Set refresh mode
       
   338 	            switch ( iNotificationsTsy->iTerminalRespData.
       
   339 	            		iCommandDetails[KCommandQualifier] )
       
   340 	                {
       
   341 	                case KSimInitFullFileChangeNotification:
       
   342 	                    {
       
   343 	                    TFLOGSTRING("CSAT: CSatNotifyRefresh::\
       
   344 	                    	CompleteNotifyL, Refresh mode: Sim init \
       
   345 	                    	and full file change notification");
       
   346 	                    refreshV2.iType = 
       
   347 	                        RSat::ESimInitFullFileChangeNotification;
       
   348 	                    iInternalCache = CSatNotificationsTsy::ECacheEFSST + 
       
   349 	                    	CSatNotificationsTsy::ECacheEFCBMID;
       
   350 	                    break;
       
   351 	                    }
       
   352 	                case KFileChangeNotification:
       
   353 	                    {
       
   354 	                    TFLOGSTRING("CSAT: CSatNotifyRefresh::CompleteNotifyL\
       
   355 	                    	Refresh mode: File Change Notification");
       
   356 	                    TFLOGSTRING2("CSAT: CSatNotifyRefresh::CompleteNotifyL\
       
   357 	                    	Number of files: %d", 
       
   358 	                    	refreshV2.iFileList.Length() );
       
   359 	                    refreshV2.iType = RSat::EFileChangeNotification;
       
   360 	                    
       
   361 	                    if ( ( KErrNotFound != refreshV2.iFileList.Locate( 
       
   362 	                         RSat::KImsiEf ) ) && 
       
   363 	                         ( !fileListTlv.GetComprehensionRequired() ) )
       
   364 	                        {
       
   365 	                        // IMSI was part of file list, CR bit was cleared
       
   366 	                        // This is done here because client does not have 
       
   367 	                        // the CR bit information available,
       
   368 	                        // Other error values comes from Client
       
   369 	                        ret = KErrCorrupt;
       
   370 	                        additionalInfo.Zero();
       
   371 	                        additionalInfo.Append( 
       
   372 	                            RSat::KNoSpecificMeProblem );
       
   373 	                        CreateTerminalRespL( pCmdNumber, 
       
   374 	                            RSat::KErrorRequiredValuesMissing,
       
   375 	                            additionalInfo ); 
       
   376 	                        }
       
   377 	                    break;
       
   378 	                    }
       
   379 	                case KSimInitFileChangeNotification:
       
   380 	                    {
       
   381 	                    TFLOGSTRING("CSAT: CSatNotifyRefresh::CompleteNotifyL,\
       
   382 	                    	Refresh mode: Sim init and file \
       
   383 	                    	change notification");
       
   384 	                    TFLOGSTRING2("CSAT: CSatNotifyRefresh::CompleteNotifyL\
       
   385 	                    	Number of files: %d", 
       
   386 	                    	refreshV2.iFileList.Length() );
       
   387 	                    refreshV2.iType = RSat::ESimInitFileChangeNotification;
       
   388 	                    break;
       
   389 	                    }
       
   390 	                case KSimInit:
       
   391 	                    {
       
   392 	                    TFLOGSTRING("CSAT: CSatNotifyRefresh::CompleteNotifyL\
       
   393 	                    	Refresh mode: Sim init ");
       
   394 	                    refreshV2.iType = RSat::ESimInit;
       
   395 	                    iInternalCache = CSatNotificationsTsy::ECacheEFSST 
       
   396 	                    	+ CSatNotificationsTsy::ECacheEFCBMID;
       
   397 	                    // Used in case of SimInit refresh + Imsi change
       
   398                         iImsiState = ERefreshSimInitReceived;
       
   399 	                    break;
       
   400 	                    }
       
   401 	                case KSimReset:
       
   402 	                    {
       
   403 	                    refreshV2.iType = RSat::ESimReset;
       
   404 	                    TFLOGSTRING("CSAT: CSatNotifyRefresh::CompleteNotifyL\
       
   405 	                    	Refresh mode: Reset");
       
   406 	                    iInternalCache = CSatNotificationsTsy::ECacheEFSST + 
       
   407 	                    	CSatNotificationsTsy::ECacheEFCBMID;
       
   408 	                    break;
       
   409 	                    }
       
   410 	                case KUSIMApplicationReset:
       
   411 	                    {
       
   412 	                    TFLOGSTRING("CSAT: CSatNotifyRefresh::CompleteNotifyL\
       
   413 	                    	Refresh mode: USIM Application Reset");
       
   414 	                    refreshV2.iType = RSat::EUsimApplicationReset;
       
   415 	                    iInternalCache = CSatNotificationsTsy::ECacheEFSST + 
       
   416 	                    	CSatNotificationsTsy::ECacheEFCBMID;
       
   417 	                    break;
       
   418 	                    }
       
   419 	                case K3GSessionReset:
       
   420 	                    {
       
   421 	                    TFLOGSTRING("CSAT: CSatNotifyRefresh::CompleteNotifyL\
       
   422 	                    	Refresh mode: 3G Session Reset");
       
   423 	                    refreshV2.iType = RSat::E3GSessionReset;
       
   424 	                    break;
       
   425 	                    }
       
   426 	                default:
       
   427 	                    {
       
   428 	                    TFLOGSTRING("CSAT: CSatNotifyRefresh::CompleteNotifyL\
       
   429 	                    	Refresh type not set!");
       
   430 	                    // This migth be an error case
       
   431 	                    refreshV2.iType = RSat::ERefreshTypeNotSet;
       
   432 	                    break;
       
   433 	                    }
       
   434 	                }
       
   435 	            
       
   436 	            // Application identifies(optional)
       
   437 	            // If an AID TLV is present, it indicates the USIM application which
       
   438 	            // needs to be refreshed. If it is not present, the ME shall assume 
       
   439 	            // the current USIM application needs to be refreshed.
       
   440 	            CTlv applicationId;     
       
   441 	            returnValue = berTlv.TlvByTagValue( &applicationId, KTlvAIDTag ); 
       
   442 	            iAid.Zero();
       
   443 	            if ( KErrNone == returnValue )
       
   444 	                {
       
   445 	                // Set application identifies
       
   446 	                refreshV2.iAid = applicationId.GetData( ETLV_AID );
       
   447 	                // Store aplication Id to member variable.
       
   448 	                iAid = refreshV2.iAid;
       
   449 	                }
       
   450 	            }
       
   451 	        // Copy parameters
       
   452 	        (*iRefreshRequiredV2Pckg)() = (*iRefreshV2Pckg)();
       
   453 	        
       
   454 	        }
       
   455         else
       
   456         	{
       
   457         	ret = aErrorCode;
       
   458         	}
       
   459 	        
       
   460         iNotificationsTsy->iSatTsy->ReqCompleted( reqHandleRefreshRequired, ret );
       
   461         }
       
   462     else
       
   463     	{        
       
   464     	TFLOGSTRING("CSAT: CSatNotifyRefresh::CompleteNotifyL,\
       
   465     	    One or more of the requests not ongoing");
       
   466         // Some of the request were not on, returning response immediately
       
   467         additionalInfo.Zero();
       
   468         additionalInfo.Append( RSat::KNoSpecificMeProblem );
       
   469         CreateTerminalRespL( pCmdNumber, RSat::KMeUnableToProcessCmd,
       
   470             additionalInfo );
       
   471         	
       
   472         ret = KErrCorrupt;    
       
   473     	}    
       
   474     return ret;
       
   475     }
       
   476 
       
   477 
       
   478 // -----------------------------------------------------------------------------
       
   479 // CSatNotifyRefresh::TerminalResponseL
       
   480 // Response for Refresh query
       
   481 // Called by ETel server, passes terminal response to DOS
       
   482 // -----------------------------------------------------------------------------
       
   483 //
       
   484 TInt CSatNotifyRefresh::TerminalResponseL
       
   485         ( 
       
   486         TDes8* aRsp
       
   487         )
       
   488     {
       
   489     TFLOGSTRING("CSAT: CSatNotifyRefresh::TerminalResponseL");
       
   490 
       
   491     RSat::TRefreshRspV1Pckg* aRspPckg = 
       
   492             reinterpret_cast<RSat::TRefreshRspV1Pckg*>( aRsp );
       
   493     RSat::TRefreshRspV1& rspV1 = ( *aRspPckg ) ();
       
   494     TBuf<1> additionalInfo;
       
   495     additionalInfo.Append( RSat::KNoSpecificMeProblem );
       
   496     // Get Proactive command number
       
   497     TUint8 pCmdNumber( rspV1.PCmdNumber() );
       
   498     
       
   499     if ( RSat::KNoAdditionalInfo != rspV1.iInfoType )
       
   500         {
       
   501         additionalInfo.Zero();
       
   502         additionalInfo.Append( rspV1.iAdditionalInfo[0] );
       
   503         }
       
   504         
       
   505     // At this point the result should be always Success 
       
   506     if ( ( ( KSimReset != iNotificationsTsy->iTerminalRespData.
       
   507     		iCommandDetails[KCommandQualifier] ) || 
       
   508     		( RSat::KSuccess != rspV1.iGeneralResult ) ) && 
       
   509     		( EImsiNotEqual != iImsiState ) )
       
   510         {
       
   511         TFLOGSTRING("CSAT: CSatNotifyRefresh::TerminalResponseL, \
       
   512         	S60 has done the Refresh" );
       
   513         // Send terminal response
       
   514         CreateTerminalRespL( pCmdNumber, (TUint8) rspV1.iGeneralResult, 
       
   515         	additionalInfo );
       
   516         // Case was not SimInit refresh + Imsi change, set back to default 
       
   517         iImsiState = ENotSet;
       
   518         }
       
   519     else
       
   520         {
       
   521         // Set flag off indicating that proactive command is not ongoing
       
   522         // Normaly this is cleared after a terminal response.
       
   523     	iNotificationsTsy->GetSatTimer()->SetProactiveCommandOnGoingStatus( 
       
   524     	    EFalse );   
       
   525     	// Case was not SimInit refresh + Imsi change, set back to default 
       
   526         iImsiState = ENotSet;
       
   527         }
       
   528         
       
   529     return KErrNone;
       
   530     }   
       
   531     
       
   532 // -----------------------------------------------------------------------------
       
   533 // CSatNotifyRefresh::CompleteImsiChange
       
   534 // Compeletes refresh request
       
   535 // -----------------------------------------------------------------------------
       
   536 //
       
   537 void CSatNotifyRefresh::CompleteImsiChange 
       
   538 		(
       
   539         // None
       
   540     	)
       
   541     {
       
   542     TFLOGSTRING("CSAT: CSatNotifyRefresh::CompleteImsiChange");
       
   543     if ( ERefreshSimInitReceived == iImsiState )
       
   544         {
       
   545         TFLOGSTRING("CSAT: CSatNotifyRefresh::CompleteImsiChange, \
       
   546             IMSI not equal");
       
   547         iImsiState = EImsiNotEqual;
       
   548         }        
       
   549     }    
       
   550    
       
   551 // -----------------------------------------------------------------------------
       
   552 // CSatNotifyRefresh::CreateTerminalRespL
       
   553 // Constructs Refresh specific part of terminal response and calls 
       
   554 // DOS to send the actual message.
       
   555 // -----------------------------------------------------------------------------
       
   556 //
       
   557 TInt CSatNotifyRefresh::CreateTerminalRespL
       
   558         ( 
       
   559         TUint8 aPCmdNumber,         
       
   560         TUint8 aGeneralResult,      
       
   561         TDesC16& aAdditionalInfo		   
       
   562 		)
       
   563     {
       
   564 	TFLOGSTRING("CSAT: CSatNotifyRefresh::CreateTerminalRespL");
       
   565     // Create and append response data
       
   566     TTlv tlvSpecificData;
       
   567     // append result tag
       
   568     tlvSpecificData.AddTag( KTlvResultTag );
       
   569 
       
   570     // General result
       
   571     tlvSpecificData.AddByte( aGeneralResult );
       
   572     
       
   573     if ( RSat::KMeUnableToProcessCmd == aGeneralResult ) 
       
   574         {
       
   575         if ( aAdditionalInfo.Length() )
       
   576         	{
       
   577         	tlvSpecificData.AddByte( ( TUint8 ) aAdditionalInfo[0] );
       
   578         	}
       
   579         }
       
   580     // Prepare data
       
   581     iNotificationsTsy->iTerminalRespData.iPCmdNumber = aPCmdNumber;
       
   582     TPtrC8 data = tlvSpecificData.GetDataWithoutTopLevelTag();
       
   583 
       
   584     // Pack data
       
   585     CSatDataPackage dataPackage;
       
   586 	dataPackage.PackData( &iNotificationsTsy->iTerminalRespData, &data );
       
   587     
       
   588     // Forward request to the DOS
       
   589     return iNotificationsTsy->iSatTsy->MessageManager()->HandleRequestL( 
       
   590 		ESatTerminalRsp, &dataPackage );
       
   591     }
       
   592 
       
   593 // -----------------------------------------------------------------------------
       
   594 // CSatNotifyRefresh::RefreshAllowedL
       
   595 // Response to RefreshRequired notify. Tells if the refresh is 
       
   596 // allowed by the Client.
       
   597 // -----------------------------------------------------------------------------
       
   598 //
       
   599 TInt CSatNotifyRefresh::RefreshAllowedL
       
   600 		(
       
   601 		const TDataPackage& aPackage
       
   602     	)
       
   603     {
       
   604     TFLOGSTRING("CSAT: CSatNotifyRefresh::RefreshAllowed ");       
       
   605     RSat::TRefreshRspV1Pckg* aRspPckg = 
       
   606             reinterpret_cast<RSat::TRefreshRspV1Pckg*>( aPackage.Des1n() );
       
   607     RSat::TRefreshRspV1& rspV1 = ( *aRspPckg ) ();
       
   608     TUint8 pCmdNumber( rspV1.PCmdNumber() );
       
   609     CSatNotificationsTsy::TRefreshInfo refreshInfo;
       
   610 	
       
   611     if ( ( RSat::KSuccess == rspV1.iGeneralResult ) || 
       
   612          ( RSat::KRefreshAdditionEFRead == rspV1.iGeneralResult ) )
       
   613         {
       
   614         // Refresh allowed
       
   615 		refreshInfo.iAid.Copy( iAid );
       
   616 		refreshInfo.iFileList.Copy( iFileList );
       
   617 		refreshInfo.iInternalCache = iInternalCache;
       
   618 		// Pack data
       
   619     	CSatDataPackage dataPackage;
       
   620 		dataPackage.PackData( &iNotificationsTsy->iTerminalRespData, &refreshInfo );	
       
   621         // Send refresh request
       
   622         iNotificationsTsy->iSatTsy->MessageManager()->HandleRequestL( 
       
   623 			ESatTsyServiceRequest, &dataPackage );			                              
       
   624         }
       
   625     else
       
   626         {
       
   627         // Refresh not allowed by the client
       
   628         TFLOGSTRING("CSAT: CSatNotifyRefresh::RefreshAllowed, refresh was not \
       
   629             allowed by the client");
       
   630 		TBuf<RSat::KAdditionalInfoMaxSize> additionalInfo;
       
   631 		additionalInfo.Append(RSat::KNoSpecificMeProblem);
       
   632         if ( RSat::KNoAdditionalInfo != rspV1.iInfoType )
       
   633             {
       
   634             additionalInfo.Zero();
       
   635             additionalInfo.Append( rspV1.iAdditionalInfo[0] );
       
   636             }
       
   637         // Send terminal response
       
   638         CreateTerminalRespL( pCmdNumber, (TUint8) rspV1.iGeneralResult, 
       
   639             additionalInfo );
       
   640         }
       
   641         
       
   642     return KErrNone;
       
   643     }
       
   644         
       
   645 // -----------------------------------------------------------------------------
       
   646 // CSatNotifyRefresh::CompleteTerminalRespDataL
       
   647 // Unpacks Refresh specific part of terminal response and calls 
       
   648 // CreateTerminalRespL to send the actual message.
       
   649 // -----------------------------------------------------------------------------
       
   650 //
       
   651 TInt CSatNotifyRefresh::CompleteTerminalRespDataL
       
   652         (
       
   653         CSatDataPackage* aDataPackage,   
       
   654         TInt /*aErrorCode*/              
       
   655         )
       
   656     {
       
   657     TFLOGSTRING("CSAT: CSatNotifyRefresh::CompleteTerminalRespDataL");
       
   658     TInt ret( KErrNone );
       
   659     CSatNotificationsTsy::TTerminalRespData* terminalRespData;
       
   660     // Send terminal response
       
   661     aDataPackage->UnPackData( &terminalRespData );
       
   662     CreateTerminalRespL( iNotificationsTsy->iTerminalRespData.iPCmdNumber,
       
   663                          terminalRespData->iGeneralResult,
       
   664                          terminalRespData->iAdditionalInfo );
       
   665     return ret;
       
   666     }
       
   667     
       
   668 // -----------------------------------------------------------------------------
       
   669 // CSatNotifyRefresh::CompleteRequest
       
   670 // Compeletes refresh request
       
   671 // -----------------------------------------------------------------------------
       
   672 //
       
   673 #ifdef USING_CTSY_DISPATCHER
       
   674 void CSatNotifyRefresh::CompleteRequest
       
   675 		(
       
   676         CSatDataPackage* /*aDataPackage*/,  
       
   677         TInt aErrorCode             
       
   678     	)
       
   679     {
       
   680     // Reset req handle. Returns the deleted req handle
       
   681     TTsyReqHandle reqHandle = iNotificationsTsy->iSatReqHandleStore->
       
   682         ResetTsyReqHandle( CSatTsy::ESatNotifyRefreshPCmdReqType );
       
   683 		
       
   684     TFLOGSTRING3("CSAT: CSatNotifyRefresh::CompleteRequest.\
       
   685     	 \n\t\t\t Handle:%d\n\t\t\t Error:%d", reqHandle, aErrorCode);
       
   686     	 		
       
   687     iNotificationsTsy->iSatTsy->ReqCompleted( reqHandle, aErrorCode);
       
   688 
       
   689     TFLOGSTRING("CSAT: CSatNotifyRefresh::CompleteRequest. Request is \
       
   690     	now completed");    
       
   691     }     
       
   692 #else //USING_CTSY_DISPATCHER
       
   693 void CSatNotifyRefresh::CompleteRequest
       
   694 		(
       
   695         CSatDataPackage* aDataPackage,  
       
   696         TInt /*aErrorCode*/              
       
   697     	)
       
   698     {
       
   699     TInt retValue;
       
   700     aDataPackage->UnPackData( retValue );
       
   701     // Reset req handle. Returns the deleted req handle
       
   702     TTsyReqHandle reqHandle = iNotificationsTsy->iSatReqHandleStore->
       
   703         ResetTsyReqHandle( CSatTsy::ESatNotifyRefreshPCmdReqType );
       
   704 
       
   705     TFLOGSTRING3("CSAT: CSatNotifyRefresh::CompleteRequest.\
       
   706     	 \n\t\t\t Handle:%d\n\t\t\t Error:%d", reqHandle, retValue);
       
   707     	 		   
       
   708     if(CSatTsy::ESatReqHandleUnknown != reqHandle) 
       
   709     	{
       
   710         iNotificationsTsy->iSatTsy->ReqCompleted( reqHandle, retValue );
       
   711 
       
   712         TFLOGSTRING("CSAT: CSatNotifyRefresh::CompleteRequest. Request is \
       
   713         	now completed");
       
   714     	} 
       
   715     
       
   716     }
       
   717 #endif //USING_CTSY_DISPATCHER
       
   718 
       
   719 // End of file
       
   720