satengine/SatServer/Commands/RefreshRequiredCmd/src/CRefreshRequiredHandler.cpp
changeset 39 cee7e9e0906c
parent 0 ff3b6d0fd310
equal deleted inserted replaced
32:1f002146abb4 39:cee7e9e0906c
     1 /*
     1 /*
     2 * Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies). 
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    28 #include    "MSatUtils.h"
    28 #include    "MSatUtils.h"
    29 #include    "MSatBIPUtils.h"
    29 #include    "MSatBIPUtils.h"
    30 #include    "MSatUiSession.h"
    30 #include    "MSatUiSession.h"
    31 #include    "SatSOpcodes.h"
    31 #include    "SatSOpcodes.h"
    32 #include    "MSatRefreshSubSession.h"
    32 #include    "MSatRefreshSubSession.h"
    33 #include    "msatmultimodeapi.h"
       
    34 #include    "SatLog.h"
    33 #include    "SatLog.h"
    35 
       
    36 // CONSTANTS
       
    37 const TInt KAidMinSize( 12 );
       
    38 
    34 
    39 
    35 
    40 // ============================ MEMBER FUNCTIONS ===============================
    36 // ============================ MEMBER FUNCTIONS ===============================
    41 
    37 
    42 // -----------------------------------------------------------------------------
    38 // -----------------------------------------------------------------------------
   364         iRefreshRequiredRsp.iGeneralResult = RSat::KMeUnableToProcessCmd;
   360         iRefreshRequiredRsp.iGeneralResult = RSat::KMeUnableToProcessCmd;
   365         iRefreshRequiredRsp.iInfoType = RSat::KMeProblem;
   361         iRefreshRequiredRsp.iInfoType = RSat::KMeProblem;
   366         iRefreshRequiredRsp.iAdditionalInfo.SetLength( 1 );
   362         iRefreshRequiredRsp.iAdditionalInfo.SetLength( 1 );
   367         iRefreshRequiredRsp.iAdditionalInfo[0] = RSat::KMeBusyOnCall;
   363         iRefreshRequiredRsp.iAdditionalInfo[0] = RSat::KMeBusyOnCall;
   368         commandAllowed = EFalse;
   364         commandAllowed = EFalse;
   369         }
       
   370     //Check the AidState.
       
   371     else
       
   372         {
       
   373         const TAidState aidState = AidState();
       
   374         LOG2( NORMAL, "REFRESHREQ: AID state: %i", aidState )
       
   375         switch ( aidState )
       
   376             {
       
   377             case EAidNotActive:
       
   378                 {
       
   379                 iRefreshRequiredRsp.iGeneralResult =
       
   380                     RSat::KRefreshUSIMNotActive;
       
   381                 iRefreshRequiredRsp.iInfoType = RSat::KNoAdditionalInfo;
       
   382                 commandAllowed = EFalse;
       
   383                 break;
       
   384                 }
       
   385 
       
   386             case EAidInvalid:
       
   387                 {
       
   388                 iRefreshRequiredRsp.iGeneralResult =
       
   389                     RSat::KCmdDataNotUnderstood;
       
   390                 iRefreshRequiredRsp.iInfoType = RSat::KNoAdditionalInfo;
       
   391                 commandAllowed = EFalse;
       
   392                 break;
       
   393                 }
       
   394 
       
   395             default:
       
   396                 {
       
   397                 LOG( NORMAL, "REFRESHREQ:   Refresh allowed" )
       
   398                 break;
       
   399                 }
       
   400             }
       
   401         }
   365         }
   402 
   366 
   403     // When refresh is not allowed, send terminal response to sim.
   367     // When refresh is not allowed, send terminal response to sim.
   404     if ( !commandAllowed )
   368     if ( !commandAllowed )
   405         {
   369         {
   759     iUtils->NotifyEvent( MSatUtils::EDelaySimSessionEnd );
   723     iUtils->NotifyEvent( MSatUtils::EDelaySimSessionEnd );
   760     Start();
   724     Start();
   761 
   725 
   762     LOG( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::RefreshAllowed exiting" )
   726     LOG( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::RefreshAllowed exiting" )
   763     }
   727     }
   764     
       
   765 // -----------------------------------------------------------------------------
       
   766 // CRefreshHandler::CheckIndicatedAid
       
   767 // Check the state of the indicated Aid.
       
   768 // -----------------------------------------------------------------------------
       
   769 //
       
   770 CRefreshRequiredHandler::TAidState 
       
   771 CRefreshRequiredHandler::AidState() const
       
   772     {
       
   773     LOG( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::AidState calling" )
       
   774 
       
   775     TAidState aidState( EAidNotActive );
       
   776     if ( !iRefreshRequiredData.iAid.Length() )
       
   777         {
       
   778         aidState = EAidNull;
       
   779         LOG( SIMPLE, "REFRESHREQ: Indicated AID Null" )
       
   780         }
       
   781     else if ( !IsValidAid( iRefreshRequiredData.iAid ) )
       
   782         {
       
   783         aidState = EAidInvalid;
       
   784         LOG( SIMPLE, "REFRESHREQ: Indicated AID Invalid" )
       
   785         }
       
   786     else
       
   787         {
       
   788         RSat::TAid aid;
       
   789         MSatAsyncToSync* wrapper = iUtils->CreateAsyncToSyncHelper();
       
   790         if ( wrapper )
       
   791             {
       
   792             iUtils->MultiModeApi().GetCurrentActiveUSimApplication(
       
   793                 wrapper->RequestStatus() , aid );
       
   794             // wait until GetCurrentActiveUSimApplication return aid
       
   795             TInt err = wrapper->SetActiveAndWait();
       
   796             LOG2( NORMAL, "REFRESHREQ: CRefreshHandler::TAidState err %d",err )
       
   797             wrapper->Release();
       
   798             
       
   799             if ( KErrNone == err )
       
   800                 {
       
   801                 #ifdef ENABLE_SAT_LOGGING
       
   802                 for ( TInt i=0; i < aid.Length(); i++ )
       
   803                     {
       
   804                     LOG2( DETAILED, "REFRESHREQ: AID from TSY: %x", aid[i] )
       
   805                     }
       
   806                 #endif
       
   807                 if ( aid == iRefreshRequiredData.iAid )
       
   808                     {
       
   809                     aidState = EAidActive;
       
   810                     }
       
   811                 }
       
   812             else if ( KErrNotSupported == err )
       
   813                 {
       
   814                 aidState = EAidActive;
       
   815                 }
       
   816             }
       
   817         LOG( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::AidState exit" )
       
   818         }
       
   819     return aidState;
       
   820     }
       
   821 
       
   822 // -----------------------------------------------------------------------------
       
   823 // Check whether the given AID is valid.
       
   824 // According to TS 110 220
       
   825 // -----------------------------------------------------------------------------
       
   826 TBool CRefreshRequiredHandler::IsValidAid( const RSat::TAid& aAid ) const
       
   827     {
       
   828     LOG( SIMPLE, "REFRESHREQ: CRefreshRequiredHandler::\
       
   829             IsValidAid calling-exiting" )
       
   830     TInt result ( EFalse );
       
   831     // Check the length of AID, it should be between 12 to 16 bytes
       
   832     // ETSI: A0,00,00,00,09;
       
   833     // 3GPP: A0,00,00,00,87
       
   834     // the fifth byte is not sure in other situations. 
       
   835     //compare the first to fourth byte
       
   836     if ( KAidMinSize <= aAid.Length() && RSat::KAidMaxSize >= aAid.Length() )
       
   837         {
       
   838         if ( EAidA0 == aAid[0]&& EAid0 == aAid[1] &&
       
   839             EAid0 == aAid[2]&& EAid0 == aAid[3] )
       
   840             {
       
   841             result = ETrue;
       
   842             }
       
   843         }
       
   844     return result;
       
   845     }
       
   846 
   728 
   847 //  End of File
   729 //  End of File