wim/WimServer/src/WimSession.cpp
changeset 0 164170e6151a
child 11 9971b621ef6c
equal deleted inserted replaced
-1:000000000000 0:164170e6151a
       
     1 /*
       
     2 * Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Session class for WimServer
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include    "WimSession.h"
       
    22 #include    "WimMemMgmt.h"
       
    23 #include    "WimCertHandler.h"
       
    24 #include    "WimAuthObjHandler.h"
       
    25 #include    "WimTokenHandler.h"
       
    26 #include    "WimKeyMgmtHandler.h"
       
    27 #include    "WimSignTextHandler.h"
       
    28 #include    "WimServer.h"
       
    29 #include    "WimResponse.h"
       
    30 #include    "WimCallbackImpl.h"
       
    31 #include    "WimUtilityFuncs.h"
       
    32 #include    "WimSessionRegistry.h"
       
    33 #include    "WimOmaProvisioning.h"
       
    34 #include    "WimJavaProvisioning.h"
       
    35 #include    "WimTrustSettingsHandler.h"
       
    36 #include    "WimTrace.h"
       
    37 
       
    38 
       
    39 // ============================ MEMBER FUNCTIONS ===============================
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // CWimSession::CWimSession
       
    43 // C++ default constructor can NOT contain any code, that
       
    44 // might leave.
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 CWimSession::CWimSession() : CSession2()
       
    48     {
       
    49     _WIMTRACE(_L("WIM | WIMServer | CWimSession::CWimSession | Begin"));
       
    50     __DECLARE_NAME( _S( "CWimSession" ) );
       
    51     }
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // CWimSession::ConstructL
       
    55 // Symbian 2nd phase constructor can leave.
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 void CWimSession::ConstructL( CWimServer* aWimServer )
       
    59     {
       
    60     _WIMTRACE(_L("WIM | WIMServer | CWimSession::ConstructL | Begin"));
       
    61     iWimSvr = aWimServer;
       
    62 #ifdef WIMSERVER_SHUTDOWN    
       
    63     iWimSvr->AddSession();
       
    64 #endif    
       
    65     iWimMgmt = CWimMemMgmt::NewL();
       
    66     iWimCertHandler = CWimCertHandler::NewL();
       
    67     iWimAuthObjHandler = CWimAuthObjHandler::NewL();
       
    68     iWimTokenHandler = CWimTokenHandler::NewL();
       
    69     iWimKeyMgmtHandler = CWimKeyMgmtHandler::NewL();
       
    70     iWimSignTextHandler = CWimSignTextHandler::NewL();
       
    71     //iTimer = CWimTimer::NewL( this );
       
    72     iWimUtilFuncs = CWimUtilityFuncs::NewL();
       
    73     iWimOmaProvisioning = CWimOmaProvisioning::NewL();
       
    74     iWimJavaProvisioning = CWimJavaProvisioning::NewL();
       
    75     iWimTrustSettingsHandler = CWimTrustSettingsHandler::NewL( iWimSvr->WimTrustSettingsStore() );
       
    76     }
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // CWimSession::NewL
       
    80 // Two-phased constructor.
       
    81 // -----------------------------------------------------------------------------
       
    82 //
       
    83 CWimSession* CWimSession::NewL( CWimServer* aWimServer )
       
    84     {
       
    85     _WIMTRACE(_L("WIM | WIMServer | CWimSession::NewL | Begin"));
       
    86     CWimSession* self = new( ELeave ) CWimSession();
       
    87     CleanupStack::PushL( self );
       
    88     self->ConstructL( aWimServer );
       
    89     CleanupStack::Pop( self );
       
    90     return self;
       
    91     }
       
    92 
       
    93 // Destructor
       
    94 CWimSession::~CWimSession()
       
    95     {
       
    96     _WIMTRACE(_L("WIM | WIMServer | CWimSession::~CWimSession | Begin"));
       
    97     
       
    98 #ifdef WIMSERVER_SHUTDOWN   
       
    99     if ( iWimSvr )
       
   100         {
       
   101         iWimSvr->DropSession();	
       
   102     	  } 
       
   103 #endif    
       
   104     //Check if message is not completed before session is desctructed
       
   105     if ( iMessage )
       
   106         {
       
   107         iMessage->Complete( KErrCancel );
       
   108         delete iMessage;
       
   109         }
       
   110 
       
   111     if ( iNotifyMessage )   // NotifyOnRemoval message pending
       
   112         {
       
   113         iNotifyMessage->Complete( KErrCancel );
       
   114         delete iNotifyMessage;
       
   115         }
       
   116 
       
   117     // Delete sessions from session registry
       
   118     if ( iWimSvr )
       
   119         {
       
   120         iWimSvr->WimSessionRegistry()->RemoveSession( this );
       
   121     	}
       
   122 
       
   123     delete iWimMgmt;
       
   124     //delete iTimer;
       
   125     delete iWimCertHandler;
       
   126     delete iWimAuthObjHandler;
       
   127     delete iWimTokenHandler;
       
   128     delete iWimKeyMgmtHandler;
       
   129     delete iWimSignTextHandler;
       
   130     delete iWimUtilFuncs;
       
   131     delete iWimOmaProvisioning;
       
   132     delete iWimJavaProvisioning;
       
   133     delete iWimTrustSettingsHandler;
       
   134     }
       
   135 
       
   136 // -----------------------------------------------------------------------------
       
   137 // CWimSession::ServiceL
       
   138 // Handles the servicing of client requests to the server.
       
   139 // -----------------------------------------------------------------------------
       
   140 //
       
   141 void CWimSession::ServiceL( const RMessage2& aMessage )
       
   142     {
       
   143     _WIMTRACE(_L("WIM | WIMServer | CWimSession::ServiceL | Begin"));
       
   144 
       
   145     iMessage = new( ELeave ) RMessage2( aMessage );
       
   146 
       
   147     TRAPD( appErr, DispatchMessageL( aMessage ) );
       
   148     // The error is an application error 
       
   149     // If the appErr is '0' or if the appErr is WIM_Error 
       
   150     // then it is completed by the called functions or by
       
   151     // the callback functions
       
   152     if ( appErr )
       
   153         {
       
   154         _WIMTRACE2(_L("WIM | WIMServer | CWimSession::ServiceL | Leaved with %d"), appErr);
       
   155         aMessage.Complete( appErr );
       
   156         }
       
   157 
       
   158     // Message is completed so delete copy of message
       
   159     delete iMessage;
       
   160     iMessage = NULL;
       
   161     }
       
   162 
       
   163 // -----------------------------------------------------------------------------
       
   164 // CWimSession::DispatchMessageL
       
   165 // Handles client requests and forwards them to appropriate handler class.
       
   166 // -----------------------------------------------------------------------------
       
   167 //
       
   168 void CWimSession::DispatchMessageL( const RMessage2& aMessage )
       
   169     {
       
   170     _WIMTRACE2(_L("WIM|WIMServer|CWimSession::DispatchMessageL|Begin, Function=%d"), aMessage.Function());
       
   171     // Check if the WIM has been initialized properly. If not just complete
       
   172     // message with WimServer status and return
       
   173     if ( CWimServer::iWimStatus != KErrNone
       
   174         && aMessage.Function() != EWimInitialize
       
   175         && aMessage.Function() != ECancelNotifyOnRemoval )
       
   176         {
       
   177         aMessage.Complete( CWimServer::iWimStatus );
       
   178         return;
       
   179         }
       
   180 
       
   181 	// Are we going to card? (blocks sim refresh until done)
       
   182 	if ( RequestAccessesHW( aMessage.Function() ))
       
   183 	    {
       
   184 	    iWimSvr->SetIsAccessingToken( ETrue );
       
   185 	    }
       
   186 
       
   187     _WIMTRACE2( _L( "WIM|WIMServer|CWimSession::DispatchMessageL|Begin, heap=%d" ),
       
   188                 User::CountAllocCells() ); 
       
   189 #ifdef __WIM_ENABLE_TRACES
       
   190 	TTime funcStart;
       
   191 	TTime funcEnd;
       
   192 	funcStart.UniversalTime();
       
   193 #endif // __WIM_ENABLE_TRACES
       
   194 
       
   195     switch ( aMessage.Function() )
       
   196         {
       
   197 //==================== WIM operations ==========================================
       
   198         case EWimInitialize:
       
   199             _WIMTRACE2(_L("WIM|WIMServer|CWimSession::DispatchMessageL|EWimInitialize, iWimInitialized=%d"), CWimServer::iWimInitialized);
       
   200             iWimSvr->WimInitialize( aMessage );
       
   201             break;
       
   202         case ECancelWimInitialize:
       
   203             iWimSvr->CancelWimInitialize( aMessage );  
       
   204             break; 
       
   205         case EGetWIMCount:
       
   206             GetWimCountL();
       
   207             break;
       
   208         case EGetWIMRefs:
       
   209             GetWimRefListL();
       
   210             break;
       
   211 
       
   212 //==================== WIM card management =====================================
       
   213         case EGetWIMInfo:
       
   214             iWimSvr->WimTimer()->ResetTimer();
       
   215             iWimTokenHandler->GetWIMInfoL( aMessage, iWimMgmt );
       
   216             break;
       
   217         case EIsWIMOpen:
       
   218             iWimTokenHandler->IsWIMOpenL( aMessage, iWimSvr->WimTimer(), iWimMgmt );
       
   219             break;
       
   220         case ECloseWIMAfter:
       
   221             iWimSvr->WimTimer()->SetCloseAfter( aMessage );
       
   222             break;
       
   223         case EGetCloseWIMAfter:
       
   224             iWimSvr->WimTimer()->GetCloseAfterL( aMessage );
       
   225             break;
       
   226         case EWimTimeRemaining:
       
   227             iWimSvr->WimTimer()->TimeRemainingL( aMessage );
       
   228             break;
       
   229         case EWIMClose:
       
   230             iWimTokenHandler->CloseWIM( aMessage );
       
   231             break;
       
   232 
       
   233 //==================== Notify on removal =======================================
       
   234         case ENotifyOnRemoval:
       
   235             NotifyOnRemovalL();
       
   236             break;
       
   237         case ECancelNotifyOnRemoval:
       
   238             CancelNotifyOnRemoval();
       
   239             break;
       
   240 
       
   241 //==================== WIM Reference handling ==================================
       
   242         case EFreeMemory:
       
   243             iWimMgmt->FreeRef( ( WIMI_Ref_pt* )aMessage.Ptr0() );  
       
   244             aMessage.Complete( KErrNone );
       
   245             break;
       
   246         case EFreeWIMMemoryLst:
       
   247             { 
       
   248             TUint wimCount = aMessage.Int1(); 
       
   249     
       
   250             WIMI_Ref_t* temp = NULL;
       
   251             TUint8 wimIndex = 0 ;
       
   252             for ( ; wimIndex < KWimMaxCount && ( temp = WIMI_GetWIMRef( wimIndex ) ) != NULL; wimIndex++ )
       
   253                 {
       
   254                 free_WIMI_Ref_t( temp );
       
   255                 }
       
   256 
       
   257             if ( wimCount != wimIndex )
       
   258                {
       
   259                User::LeaveIfError( KErrArgument );
       
   260                }
       
   261     
       
   262             iWimMgmt->FreeWIMRefs( aMessage );  
       
   263             break;
       
   264             }
       
   265         case EFreeMemoryLst:
       
   266             iWimMgmt->FreeRefLst( aMessage );
       
   267             break;
       
   268 
       
   269 //==================== PIN operations ==========================================
       
   270         case EGetPINCount:
       
   271             iWimSvr->WimTimer()->ResetTimer();
       
   272             iWimAuthObjHandler->GetPINCountL( aMessage );
       
   273             break;
       
   274         case EGetPINRefs:
       
   275             iWimSvr->WimTimer()->ResetTimer();
       
   276             iWimAuthObjHandler->GetPINRefListL( aMessage, iWimMgmt );
       
   277             break;
       
   278         case EGetPINInfo:
       
   279             iWimSvr->WimTimer()->ResetTimer();
       
   280             iWimAuthObjHandler->GetPINInfoL( aMessage );
       
   281             break;
       
   282         case EGetPINsInfo:
       
   283             iWimSvr->WimTimer()->ResetTimer();
       
   284             iWimAuthObjHandler->GetPINsInfoL( aMessage ); 
       
   285             break;
       
   286         case EIsPinBlocked:
       
   287             iWimAuthObjHandler->VerifyPINRequestL( aMessage, EFalse );
       
   288             break;
       
   289         case EIsDisabledPinBlocked:
       
   290             iWimAuthObjHandler->VerifyDisabledPINRequestL( aMessage );
       
   291             break;
       
   292         case EChangePINReq:
       
   293             iWimSvr->WimTimer()->ResetTimer();
       
   294             iWimAuthObjHandler->ChangePINRequestL( aMessage );
       
   295             break;
       
   296         case ECancelChangePin:
       
   297             iWimAuthObjHandler->CancelChangePin( aMessage );
       
   298             break;
       
   299         case EEnablePINReq:
       
   300             iWimSvr->WimTimer()->ResetTimer();
       
   301             iWimAuthObjHandler->EnablePINReqL( aMessage );
       
   302             break;
       
   303         case ECancelEnablePin:
       
   304             iWimAuthObjHandler->CancelEnablePin( aMessage );
       
   305             break;
       
   306         case EUnblockPinReq:
       
   307             iWimSvr->WimTimer()->ResetTimer();
       
   308             iWimAuthObjHandler->UnblockPinReqL( aMessage );
       
   309             break;
       
   310         case ECancelUnblockPin:
       
   311             iWimAuthObjHandler->CancelUnblockPin( aMessage );
       
   312             break;
       
   313         case EVerifyPinReq:
       
   314             iWimSvr->WimTimer()->ResetTimer();
       
   315             iWimAuthObjHandler->VerifyPINRequestL( aMessage, ETrue );
       
   316             break;
       
   317         case ECancelVerifyPin:
       
   318             iWimAuthObjHandler->CancelVerifyPin( aMessage );
       
   319             break;
       
   320         case ERetrieveAuthObjsInfo:
       
   321             iWimAuthObjHandler->RetrieveAuthObjectsInfo( aMessage ); 
       
   322             break;
       
   323 
       
   324 //==================== Key operations ==========================================
       
   325         case EGetKeyDetails:
       
   326             iWimKeyMgmtHandler->GetKeyDetailsL( aMessage );
       
   327             break;
       
   328         case EGetKeyList:
       
   329             iWimKeyMgmtHandler->GetKeyListL( aMessage, iWimMgmt );
       
   330             break;
       
   331         case EDoesPvKeyExist:
       
   332             iWimKeyMgmtHandler->DoesKeyExistL( aMessage );
       
   333             break; 
       
   334 
       
   335 //==================== Certificate Management ==================================
       
   336         case EGetWIMCertLst:
       
   337             iWimCertHandler->GetCertificatesFromWimL( aMessage, iWimMgmt );
       
   338             break;
       
   339         case EGetCertCount:
       
   340             iWimCertHandler->GetCerticateCountL( aMessage, iWimMgmt );
       
   341             break;
       
   342         case EGetWIMCertDetails:
       
   343             iWimCertHandler->GetCertificateDetailsL( EGetWIMCertDetails,
       
   344                                                      aMessage );
       
   345             break;
       
   346         case EGetCertExtras:    // Get cert extra data (e.g. trusted usage)
       
   347             iWimCertHandler->GetExtrasFromWimL( aMessage, iWimMgmt );
       
   348             break;
       
   349         case EStoreCertificate:
       
   350             iWimCertHandler->StoreCertificateL( EStoreCertificate, aMessage );
       
   351             break;
       
   352         case ERemoveCertificate:
       
   353             iWimCertHandler->RemoveCertificateL( aMessage, iWimMgmt );
       
   354             break;
       
   355         case EExportPublicKey:
       
   356             iWimCertHandler->ExportPublicKeyL( aMessage );
       
   357             break;
       
   358 
       
   359 //==================== Digital signature =======================================
       
   360         case ESignTextReq:
       
   361             iWimSignTextHandler->SignTextL( aMessage );
       
   362             break;
       
   363 
       
   364 //==================== Java Provisioning ========================================
       
   365         case EGetACIFFileSize:
       
   366             iWimJavaProvisioning->ACIFFileSizeL( aMessage );
       
   367             break;
       
   368         case EGetACIFFile:
       
   369             iWimJavaProvisioning->ACIFFileContentL( aMessage );
       
   370             break;
       
   371         case EGetACFFileSize:
       
   372             iWimJavaProvisioning->ACFFileSizeL( aMessage );
       
   373             break;
       
   374         case EGetACFFile:
       
   375             iWimJavaProvisioning->ACFFileContentL( aMessage );
       
   376             break;    
       
   377         case EGetLabelAndPath:
       
   378             iWimJavaProvisioning->LabelAndPath( aMessage );
       
   379             break;
       
   380             
       
   381 //==================== OMA Provisioning ========================================
       
   382         case EGetOMAFileSize:
       
   383             iWimOmaProvisioning->OmaFileSizeL( aMessage );
       
   384             break;
       
   385         case EGetOMAFile:
       
   386             iWimOmaProvisioning->OmaFileContentL( aMessage );
       
   387             break;            
       
   388 
       
   389 //==================== Trust Settings  =========================================
       
   390         case EGetTrustSettings:
       
   391             iWimTrustSettingsHandler->GetTrustSettingsL( aMessage );
       
   392             break;
       
   393         case ESetApplicability: 
       
   394             iWimTrustSettingsHandler->SetApplicabilityL( aMessage );
       
   395             break;
       
   396         case ESetTrust:
       
   397             iWimTrustSettingsHandler->SetTrustL( aMessage );
       
   398             break;
       
   399         case ESetDefaultTrustSettings:
       
   400             iWimTrustSettingsHandler->SetDefaultTrustSettingsL( aMessage );
       
   401             break;
       
   402         case ERemoveTrustSettings:
       
   403             iWimTrustSettingsHandler->RemoveTrustSettingsL( aMessage );
       
   404             break;
       
   405         case ECancelTrustSettings:
       
   406             iWimTrustSettingsHandler->CancelDoing();
       
   407             break;
       
   408 
       
   409 //==================== Opcode not supported ====================================
       
   410         default:
       
   411             aMessage.Complete( KErrArgument );
       
   412             break;
       
   413         }
       
   414 #ifdef __WIM_ENABLE_TRACES
       
   415     funcEnd.UniversalTime();
       
   416     TTimeIntervalMicroSeconds funcTime = funcEnd.MicroSecondsFrom( funcStart );
       
   417     _WIMTRACE3( _L("WIMServer function %d, time %Ld us"), aMessage.Function(), funcTime.Int64() );
       
   418 	
       
   419     TInt allocSize = 0;
       
   420     TInt allocCount = User::AllocSize( allocSize );
       
   421     _WIMTRACE3( _L( "WIM|WIMServer|CWimSession::DispatchMessageL|End, heap=%d, heapsize=%d" ), allocCount, allocSize );
       
   422 #endif // __WIM_ENABLE_TRACES
       
   423 
       
   424     // Assuming that WIMI calls are asynchronous
       
   425     iWimSvr->SetIsAccessingToken( EFalse ); // HW access complete
       
   426 
       
   427     // Has the card data been modified during service? -> re-init
       
   428     if ( iWimSvr->RefreshNotificationReceived() )
       
   429         {
       
   430         iWimSvr->SetRefreshNotificationReceived( EFalse );
       
   431         RefreshWimi();
       
   432         }
       
   433     }
       
   434 
       
   435 // -----------------------------------------------------------------------------
       
   436 // CWimSession::GetWimRefListL
       
   437 // Fetches the list of the references of WIMs currently associated with readers.
       
   438 // -----------------------------------------------------------------------------
       
   439 //
       
   440 void CWimSession::GetWimRefListL()
       
   441     {
       
   442     _WIMTRACE(_L("WIM | WIMServer | CWimSession::GetWIMRefListL | Begin"));
       
   443     WIMI_Ref_pt pWimRefTemp = NULL;
       
   444 
       
   445     HBufC8* buf = iWimUtilFuncs->DesLC( 0, *iMessage );
       
   446     TUint32* wimRef =  ( TUint32* )( buf->Des().Ptr() );
       
   447     TUint8 wimIndex = 0;
       
   448     for ( ; wimIndex < KWimMaxCount && 
       
   449             ( pWimRefTemp = WIMI_GetWIMRef( wimIndex ) ) != NULL; wimIndex++ )
       
   450         {
       
   451         wimRef[wimIndex] = ( TUint32 )pWimRefTemp;
       
   452         iWimMgmt->AppendWIMRefL( pWimRefTemp );     // takes ownership
       
   453         }
       
   454     iMessage->WriteL( 0, buf->Des() );
       
   455     CleanupStack::PopAndDestroy( buf );
       
   456 
       
   457     iMessage->Complete( KErrNone );
       
   458     }
       
   459 
       
   460 // -----------------------------------------------------------------------------
       
   461 // CWimSession::GetWimCountL
       
   462 // Fetches the count of WIM cards in use.
       
   463 // -----------------------------------------------------------------------------
       
   464 //
       
   465 void CWimSession::GetWimCountL()
       
   466     {
       
   467     _WIMTRACE(_L("WIM | WIMServer | CWimSession::GetWimCountL | Begin"));
       
   468     WIMI_Ref_t* temp = NULL;
       
   469     TUint8 wimIndex = 0 ;
       
   470     for ( ; wimIndex < KWimMaxCount &&
       
   471         ( temp = WIMI_GetWIMRef( wimIndex ) ) != NULL; wimIndex++ )
       
   472         {
       
   473         free_WIMI_Ref_t( temp );
       
   474         }
       
   475 
       
   476     TPckgBuf<TUint> pckg( wimIndex );
       
   477     iMessage->WriteL( 0, pckg );
       
   478     iMessage->Complete( KErrNone );
       
   479     }
       
   480 
       
   481 // -----------------------------------------------------------------------------
       
   482 // CWimSession::TimerExpired
       
   483 // Timer for closing WIM card. WIM is opened again with EVerifyPinReq after
       
   484 // new initialization.
       
   485 // -----------------------------------------------------------------------------
       
   486 //
       
   487 void CWimSession::TimerExpired()
       
   488     {
       
   489     _WIMTRACE(_L("WIM | WIMServer | CWimSession::TimerExpired | Begin"));
       
   490     WIMI_Ref_pt pWimRefTemp = NULL;
       
   491 
       
   492     pWimRefTemp = WIMI_GetWIMRef( 0 );
       
   493  
       
   494     if ( pWimRefTemp )  // Close the WIM
       
   495         {
       
   496         WIMI_CloseWIM( pWimRefTemp );
       
   497         free_WIMI_Ref_t( pWimRefTemp );
       
   498         }
       
   499     CWimServer::SetWimInitialized( EFalse, KErrNone );
       
   500     }
       
   501 
       
   502 // -----------------------------------------------------------------------------
       
   503 // CWimSession::NotifyOnRemoval
       
   504 // Notify on card removal. Store message for completing.
       
   505 // -----------------------------------------------------------------------------
       
   506 //
       
   507 void CWimSession::NotifyOnRemovalL()
       
   508     {
       
   509     _WIMTRACE(_L("WIM | WIMServer | CWimSession::NotifyOnRemoval | Begin"));
       
   510     if ( iNotifyMessage ) // Message already pending
       
   511         {
       
   512         _WIMTRACE(_L("WIM|WIMServer|CWimSession::NotifyOnRemoval|KErrAlreadyExists"));
       
   513         iMessage->Complete( KErrAlreadyExists );
       
   514         return;
       
   515         }
       
   516     iNotifyMessage = new( ELeave ) RMessage2( *iMessage ); // Store message
       
   517     _WIMTRACE(_L("WIM|WIMServer|CWimSession::NotifyOnRemoval|iNotifyMessage created"));
       
   518     }
       
   519 
       
   520 // -----------------------------------------------------------------------------
       
   521 // CWimSession::CancelNotifyOnRemoval
       
   522 // Cancels NotifyOnRemoval request if it is pending.
       
   523 // -----------------------------------------------------------------------------
       
   524 //
       
   525 void CWimSession::CancelNotifyOnRemoval()
       
   526     {
       
   527     _WIMTRACE(_L("WIM | WIMServer | CWimSession::CancelNotifyOnRemoval | Begin"));
       
   528     if ( iNotifyMessage )
       
   529         {
       
   530         _WIMTRACE(_L("WIM | WIMServer | CWimSession::CancelNotifyOnRemoval | iNotifyMessage completed with KErrCancel"));
       
   531         iNotifyMessage->Complete( KErrCancel ); // Complete pending message
       
   532         delete iNotifyMessage;
       
   533         iNotifyMessage = NULL;
       
   534         }
       
   535     _WIMTRACE(_L("WIM | WIMServer | CWimSession::CancelNotifyOnRemoval | Message completed with KErrNone"));
       
   536     iMessage->Complete( KErrNone ); // Complete Cancel message
       
   537     }
       
   538 
       
   539 // -----------------------------------------------------------------------------
       
   540 // CWimSession::NotifyComplete
       
   541 // Complete NotifyOnRemoval message
       
   542 // -----------------------------------------------------------------------------
       
   543 //
       
   544 void CWimSession::NotifyComplete()
       
   545     {
       
   546     _WIMTRACE(_L("WIM | WIMServer | CWimSession::NotifyComplete | Begin"));
       
   547     if ( iNotifyMessage )
       
   548         {
       
   549         iNotifyMessage->Complete( KErrNone );
       
   550         delete iNotifyMessage;
       
   551         iNotifyMessage = NULL;
       
   552         }
       
   553     }
       
   554 
       
   555 
       
   556 // -----------------------------------------------------------------------------
       
   557 // CWimSession::RequestAccessesHW
       
   558 // Check if current request accesses HW
       
   559 // -----------------------------------------------------------------------------
       
   560 //
       
   561 TBool CWimSession::RequestAccessesHW( TInt aFunction )
       
   562 	{
       
   563 	TBool rc( EFalse );
       
   564 
       
   565 	switch ( aFunction )
       
   566 		{
       
   567         // Requests that access HW
       
   568         case EWimInitialize:        //lint -fallthrough
       
   569 //==================== WIM card management =====================================
       
   570         case EWIMClose:             //lint -fallthrough
       
   571 //==================== PIN operations ==========================================
       
   572         case EIsPinBlocked:         //lint -fallthrough
       
   573         case EChangePINReq:         //lint -fallthrough
       
   574         case EEnablePINReq:         //lint -fallthrough
       
   575         case EUnblockPinReq:        //lint -fallthrough
       
   576         case EVerifyPinReq:         //lint -fallthrough
       
   577 //==================== Certificate Management ==================================
       
   578         case EGetWIMCertDetails:    //lint -fallthrough
       
   579         case EStoreCertificate:     //lint -fallthrough
       
   580         case ERemoveCertificate:    //lint -fallthrough
       
   581         case EExportPublicKey:      //lint -fallthrough
       
   582 //==================== Digital signature =======================================
       
   583         case ESignTextReq:          //lint -fallthrough
       
   584 //==================== OMA Provisioning ========================================
       
   585         case EGetOMAFileSize:       //lint -fallthrough
       
   586         case EGetOMAFile:
       
   587 //==================== JAVA Proisioning ========================================
       
   588 		case EGetACIFFileSize:
       
   589 		case EGetACIFFile:
       
   590 		case EGetACFFileSize:
       
   591 		case EGetACFFile:
       
   592 	    case EGetLabelAndPath:        
       
   593 			rc = ETrue;
       
   594             break;
       
   595 
       
   596         // Request does not access HW
       
   597         default:
       
   598             break;
       
   599 		}
       
   600 	return rc;
       
   601 	}
       
   602 
       
   603 
       
   604 // -----------------------------------------------------------------------------
       
   605 // CWimSession::RefreshWimi
       
   606 // Data on card has changed, re-init Wimi.
       
   607 // -----------------------------------------------------------------------------
       
   608 //
       
   609 void CWimSession::RefreshWimi()
       
   610     {
       
   611     RArray<CWimSession*> sessions;
       
   612     TRAPD( err, iWimSvr->GetSessionsL( sessions ));
       
   613 
       
   614     if ( !err )  // Got sessions correctly
       
   615         {
       
   616         TInt count = sessions.Count();
       
   617         // Loop through all sessions and notify all clients that are
       
   618         // requesting the notification
       
   619         for ( TInt i( 0 ); i < count; i++ )
       
   620             {
       
   621             sessions[i]->NotifyComplete();
       
   622             }
       
   623         sessions.Reset();
       
   624         // Close WIMI
       
   625         WIMI_CloseDownReq();
       
   626         _WIMTRACE(_L("WIM | CWimSession::RefreshWimi | WIMI closed."));
       
   627         }
       
   628     else
       
   629         {
       
   630         _WIMTRACE(_L("WIM | CWimSession::RefreshWimi: FAILED to get sessions."));
       
   631         }
       
   632     }
       
   633 
       
   634 //  End of File