wim/WimClient/src/WimSecModule.cpp
changeset 0 164170e6151a
child 5 3b17fc5c9564
equal deleted inserted replaced
-1:000000000000 0:164170e6151a
       
     1 /*
       
     2 * Copyright (c) 2002 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:  API for managing WIM Security Module.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 //INCLUDES
       
    20 #include "WimSecModule.h"
       
    21 #include "WimConsts.h"
       
    22 #include "WimPin.h"
       
    23 #include "WimMgmt.h"
       
    24 #include "WimTrace.h"
       
    25 
       
    26 //CONSTANTS
       
    27 _LIT( KZeroHex,"0%x" );
       
    28 _LIT( KHex, "%x" );
       
    29 //Must be const, else this won't compile to Thumb & arm4
       
    30 const TUint KSerialNumberMask = 0x0F; 
       
    31 const TUint KPinNum = 0x02;	
       
    32 
       
    33 //================= MEMBER FUNCTIONS  for CWimSecModule=======================
       
    34 //
       
    35 //  C++ default constructor. Initialize the member variables
       
    36 //
       
    37 //
       
    38 CWimSecModule::CWimSecModule( TWimAddress aWimAddr ): CActive( EPriorityHigh ),
       
    39                                                       iReference( aWimAddr ),
       
    40                                                       iPinNRsInit( EFalse )
       
    41     {
       
    42     }
       
    43 
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 // CWimSecModule::NewL()
       
    47 // Two-phased constructor.
       
    48 // -----------------------------------------------------------------------------
       
    49 //
       
    50 EXPORT_C CWimSecModule* CWimSecModule::NewL( TWimAddress aWimAddr )
       
    51     {
       
    52     _WIMTRACE ( _L( "CWimSecModule::NewL()" ) );
       
    53     __ASSERT_DEBUG( aWimAddr, User::Leave( KErrArgument ) );    
       
    54     CWimSecModule* self = new( ELeave ) CWimSecModule( aWimAddr );
       
    55     CleanupStack::PushL( self );
       
    56     self->ConstructL();
       
    57     CleanupStack::Pop( self ); //self
       
    58     return self;
       
    59     }
       
    60 
       
    61 // -----------------------------------------------------------------------------
       
    62 // CWimSecModule::ConstructL()
       
    63 // Symbian 2nd phase constructor can leave.
       
    64 // -----------------------------------------------------------------------------
       
    65 //
       
    66 void CWimSecModule::ConstructL()
       
    67     {
       
    68     CActiveScheduler::Add( this );
       
    69     _WIMTRACE ( _L( "CWimSecModule::ConstructL()" ) );
       
    70     iLabel = HBufC::NewL( KLabelLen );
       
    71     iManufacturer = HBufC::NewL( KManufacturerLen );
       
    72     iSerialNumber = HBufC::NewL( KSerialNumberLen );
       
    73     iPinInfoLst = new( ELeave )CArrayFixFlat<TWimPinStruct>(KPinNum);
       
    74     }
       
    75 
       
    76 // -----------------------------------------------------------------------------
       
    77 // CWimSecModule::IsOpen()
       
    78 // Checks is WIM already open.
       
    79 // -----------------------------------------------------------------------------
       
    80 //
       
    81 EXPORT_C TBool CWimSecModule::IsOpen()
       
    82     {
       
    83     _WIMTRACE ( _L( "CWimSecModule::IsOpen()" ) );
       
    84     return iClientSession->IsOpen( iReference ); 
       
    85     }
       
    86 
       
    87 
       
    88 // -----------------------------------------------------------------------------
       
    89 // CWimSecModule::CloseAfter()
       
    90 // Returns the time which is set as WIM closeout time
       
    91 // -----------------------------------------------------------------------------
       
    92 //
       
    93 EXPORT_C TInt CWimSecModule::CloseAfter()
       
    94     {
       
    95     _WIMTRACE ( _L( "CWimSecModule::CloseAfter()" ) );
       
    96     return iClientSession->CloseAfter();  
       
    97     }
       
    98 
       
    99 // -----------------------------------------------------------------------------
       
   100 // CWimSecModule::TimeRemaining()
       
   101 // Returns the timeout which tells how long WIM Security Module will be open 
       
   102 // after it is opened.
       
   103 // -----------------------------------------------------------------------------
       
   104 //
       
   105 EXPORT_C TInt CWimSecModule::TimeRemaining()
       
   106     {
       
   107     _WIMTRACE ( _L( "CWimSecModule::TimeRemaining()" ) );
       
   108     return iClientSession->TimeRemaining( );      
       
   109     }
       
   110 
       
   111 // -----------------------------------------------------------------------------
       
   112 // CWimSecModule::PinNrEntriesL()
       
   113 // Returns WIM Security Module's keys' PIN-NR objects in array.
       
   114 // -----------------------------------------------------------------------------
       
   115 //
       
   116 EXPORT_C TInt CWimSecModule::PinNrEntriesL( 
       
   117                                       const CArrayPtrFlat<CWimPin>*& aPinNRs,
       
   118                                       TRequestStatus& aStatus ) 
       
   119     {
       
   120     _WIMTRACE ( _L( "CWimSecModule::PinNrEntriesL()" ) );
       
   121     TInt status = KErrNone;
       
   122     
       
   123     if( !iPinNRsInit )
       
   124 	    {
       
   125 	    status = GetPINModulesL( aStatus );	
       
   126 	    }
       
   127     else
       
   128         {
       
   129     	aPinNRs = iPinNRs;
       
   130     	iClientStatus = &aStatus;
       
   131     	User::RequestComplete( iClientStatus, KErrNone );
       
   132     	return status;
       
   133         }
       
   134     
       
   135     if ( status == KErrNone )
       
   136         {
       
   137         aPinNRs = iPinNRs;
       
   138         }
       
   139     else
       
   140         {
       
   141         aPinNRs = NULL;
       
   142         }
       
   143     return status;
       
   144     }
       
   145 
       
   146 // -----------------------------------------------------------------------------
       
   147 // CWimSecModule::PinNrEntriesL()
       
   148 // Returns WIM Security Module's keys' PIN-NR objects in array.
       
   149 // -----------------------------------------------------------------------------
       
   150 //
       
   151 EXPORT_C TInt CWimSecModule::PinNrEntriesL( 
       
   152                                       const CArrayPtrFlat<CWimPin>*& aPinNRs ) 
       
   153     {
       
   154     _WIMTRACE ( _L( "CWimSecModule::PinNrEntriesL()" ) );
       
   155     TInt status = KErrNone;
       
   156    
       
   157    if( !iPinNRsInit )
       
   158        {
       
   159    	   status = GetPINModulesL();
       
   160        }
       
   161     
       
   162     if ( status == KErrNone )
       
   163         {
       
   164         aPinNRs = iPinNRs;
       
   165         }
       
   166     else
       
   167         {
       
   168         aPinNRs = NULL;
       
   169         }
       
   170     return status;
       
   171     }
       
   172 
       
   173 // -----------------------------------------------------------------------------
       
   174 // CWimSecModule::Label()
       
   175 // Returns WIM's label.
       
   176 // -----------------------------------------------------------------------------
       
   177 //
       
   178 EXPORT_C TPtrC CWimSecModule::Label()
       
   179     {
       
   180     _WIMTRACE ( _L( "CWimSecModule::Label()" ) );
       
   181     TInt status = KErrNone;
       
   182     TRAPD( err, status = GetWIMInfoL() );
       
   183     if ( status == KErrNone && !err )
       
   184         {
       
   185         return iLabel->Des();
       
   186         }
       
   187     else
       
   188         {
       
   189         return TPtrC( NULL, 0 );
       
   190         }
       
   191     }
       
   192 
       
   193 
       
   194 // -----------------------------------------------------------------------------
       
   195 // CWimSecModule::Manufacturer()
       
   196 // Returns WIM's manufacturer.
       
   197 // -----------------------------------------------------------------------------
       
   198 //
       
   199 EXPORT_C const TDesC& CWimSecModule::Manufacturer()
       
   200     {
       
   201     _WIMTRACE ( _L( "CWimSecModule::Manufacturer()" ) );
       
   202     TInt status = KErrNone;
       
   203     TRAPD( err, status = GetWIMInfoL() );
       
   204     if ( status == KErrNone && !err )
       
   205         {
       
   206         return *iManufacturer;
       
   207         }
       
   208     else
       
   209         {
       
   210         return KNullDesC;
       
   211         }
       
   212     }
       
   213 
       
   214 
       
   215 // -----------------------------------------------------------------------------
       
   216 // CWimSecModule::Version()
       
   217 // Returns WIM's version.
       
   218 // -----------------------------------------------------------------------------
       
   219 //
       
   220 EXPORT_C const TDesC& CWimSecModule::Version()
       
   221     { 
       
   222     _WIMTRACE ( _L( "CWimSecModule::Version()" ) );
       
   223     TInt status = KErrNone;
       
   224     TRAPD( err, status = GetWIMInfoL() );
       
   225     if ( status == KErrNone && !err )
       
   226         {
       
   227         return *iVersion;
       
   228         }
       
   229     else
       
   230         {
       
   231         return KNullDesC;   
       
   232         }
       
   233     }
       
   234 
       
   235 
       
   236 // -----------------------------------------------------------------------------
       
   237 // CWimSecModule::SerialNumber()
       
   238 // Returns WIM's serial number which identifies it.
       
   239 // -----------------------------------------------------------------------------
       
   240 //
       
   241 EXPORT_C const TDesC& CWimSecModule::SerialNumber()
       
   242     {
       
   243     _WIMTRACE ( _L( "CWimSecModule::SerialNumber()" ) );
       
   244     TInt status = KErrNone;
       
   245     TRAPD( err, status = GetWIMInfoL() );
       
   246     if ( status == KErrNone && !err )
       
   247         {
       
   248         return *iSerialNumber; 
       
   249         }
       
   250     else
       
   251         {
       
   252         return KNullDesC;
       
   253         }
       
   254     }
       
   255  
       
   256 
       
   257 
       
   258 // -----------------------------------------------------------------------------
       
   259 // CWimSecModule::Close()
       
   260 // Closes the parts of WIM which is opened with PIN-G.
       
   261 // -----------------------------------------------------------------------------
       
   262 //
       
   263 EXPORT_C TInt CWimSecModule::Close()
       
   264     {
       
   265     _WIMTRACE ( _L( "CWimSecModule::Close()" ) );
       
   266     
       
   267     iWimInfoConstructed = EFalse;
       
   268     iPinNRsInit = EFalse;
       
   269     
       
   270     if ( iReference )
       
   271         {
       
   272         return iClientSession->CloseWIM( iReference );
       
   273         }
       
   274     else
       
   275         {
       
   276         return KWimSMInfoError;
       
   277         }
       
   278     }
       
   279 
       
   280 // -----------------------------------------------------------------------------
       
   281 // CWimSecModule::SetCloseAfter()
       
   282 // Sets the timeout which defines the time after WIM is automatically closed.
       
   283 // -----------------------------------------------------------------------------
       
   284 //
       
   285 EXPORT_C void CWimSecModule::SetCloseAfter( const TUint aTimeout )
       
   286     {
       
   287     _WIMTRACE ( _L( "CWimSecModule::SetCloseAfter()" ) );
       
   288     iClientSession->SetCloseAfter( aTimeout );
       
   289     }
       
   290 
       
   291 
       
   292 // -----------------------------------------------------------------------------
       
   293 // CWimSecModule::~CWimSecModule()
       
   294 // Destructor, all allocated memory is released.
       
   295 // -----------------------------------------------------------------------------
       
   296 //
       
   297 EXPORT_C CWimSecModule::~CWimSecModule()
       
   298     {
       
   299     _WIMTRACE ( _L( "CWimSecModule::~CWimSecModule()()" ) );
       
   300     Cancel();
       
   301     
       
   302     if( iPinInfoLst )
       
   303         {
       
   304     	iPinInfoLst->Reset();
       
   305     	delete iPinInfoLst;
       
   306         }
       
   307     if ( iPinLstAddr )
       
   308         {
       
   309         iClientSession->FreeAddrLst( iPinLstAddr );
       
   310         }
       
   311     if ( iPinNRs )
       
   312         {
       
   313         iPinNRs->ResetAndDestroy();/* Destroy  */
       
   314         delete iPinNRs;    /* Array of pointers to PIN-NRs. */
       
   315         }
       
   316     if ( iRefPing )
       
   317         {
       
   318         iClientSession->FreeWIMAddr( iRefPing );
       
   319         }
       
   320     delete iLabel;
       
   321     delete iManufacturer;
       
   322     delete iSerialNumber;
       
   323     if ( iVersion )
       
   324         {
       
   325         delete iVersion;
       
   326         iVersion = NULL;
       
   327         }
       
   328    
       
   329     }
       
   330 
       
   331 // -----------------------------------------------------------------------------
       
   332 // CWimSecModule::TokenNumber()
       
   333 // Returns TUint8 iReader which identifies the slot 
       
   334 // where the WIM card is actually.
       
   335 // -----------------------------------------------------------------------------
       
   336 //
       
   337 EXPORT_C TUint8 CWimSecModule::TokenNumber()
       
   338     {
       
   339     _WIMTRACE ( _L( "CWimSecModule::TokenNumber()" ) );
       
   340     return iReader;
       
   341     }
       
   342 
       
   343 // -----------------------------------------------------------------------------
       
   344 // CWimSecModule::NotifyOnRemoval()
       
   345 // Notifies the client when the token has been removed.
       
   346 // -----------------------------------------------------------------------------
       
   347 //
       
   348 EXPORT_C void CWimSecModule::NotifyOnRemoval( TRequestStatus& aStatus )
       
   349     {
       
   350     _WIMTRACE ( _L( "CWimSecModule::NotifyOnRemoval()" ) );
       
   351 
       
   352     TIpcArgs args;
       
   353     iClientSession->SendReceiveData( ENotifyOnRemoval, args, aStatus );
       
   354     }
       
   355 
       
   356 // -----------------------------------------------------------------------------
       
   357 // CWimSecModule::CancelNotifyOnRemoval()
       
   358 // Cancels the NotifyOnRemoval request.
       
   359 // -----------------------------------------------------------------------------
       
   360 //
       
   361 EXPORT_C void CWimSecModule::CancelNotifyOnRemoval()
       
   362     {
       
   363     _WIMTRACE ( _L( "CWimSecModule::CancelNotifyOnRemoval()" ) );
       
   364 
       
   365     TIpcArgs args;
       
   366     iClientSession->SendReceiveData( ECancelNotifyOnRemoval, args );
       
   367     }
       
   368 
       
   369 // -----------------------------------------------------------------------------
       
   370 // CWimSecModule::GetWIMInfoL()
       
   371 // Gets label,manufacturer,serialnumber and the number of the slot 
       
   372 // where card is.
       
   373 // -----------------------------------------------------------------------------
       
   374 //
       
   375 TInt CWimSecModule::GetWIMInfoL()
       
   376     {
       
   377     _WIMTRACE ( _L( "CWimSecModule::GetWIMInfoL()" ) );
       
   378 
       
   379     TBuf<KVersionNumberLen> temporalVersionNum;   
       
   380 
       
   381     TInt status = KErrNone;
       
   382     if ( !iWimInfoConstructed )
       
   383         {
       
   384         HBufC* temporalSerialNumber = HBufC::NewLC( KSerialNumberLen );                
       
   385         TWimSecModuleStruct wimSecModuleStruct;
       
   386         TPtr label = iLabel->Des();
       
   387         TPtr manufacturer = iManufacturer->Des();
       
   388         TPtr serialnumber = temporalSerialNumber->Des();
       
   389         wimSecModuleStruct.iLabel = label;
       
   390         wimSecModuleStruct.iManufacturer = manufacturer;
       
   391         wimSecModuleStruct.iSerialNumber = serialnumber;
       
   392         status = iClientSession->WIMInfo( iReference, wimSecModuleStruct );
       
   393         if ( status == KErrNone ) 
       
   394             {
       
   395             temporalVersionNum.Num( ( TInt )wimSecModuleStruct.iVersion );
       
   396             iVersion = temporalVersionNum.AllocL();
       
   397             iReader = wimSecModuleStruct.iReader;
       
   398             label.Copy( wimSecModuleStruct.iLabel );
       
   399             manufacturer.Copy( wimSecModuleStruct.iManufacturer );
       
   400             serialnumber.Copy( wimSecModuleStruct.iSerialNumber );
       
   401             label.ZeroTerminate();
       
   402             manufacturer.ZeroTerminate();
       
   403             serialnumber.ZeroTerminate();
       
   404             iRefPing = wimSecModuleStruct.iRefPinG;
       
   405             
       
   406             //status = GetPINModulesL( aStatus );
       
   407             
       
   408             if ( status == KErrNone )
       
   409                 {
       
   410                 if ( iReader != KSoftId )
       
   411                     {
       
   412                     ConvertSerialNumberL( temporalSerialNumber );                    
       
   413                     }
       
   414                 else
       
   415                     {
       
   416                     TBuf<KVersionNumberLen> newSerialNumber;
       
   417                     TPtr ptr = temporalSerialNumber->Des();
       
   418                     newSerialNumber.Copy( ptr ); 
       
   419                     delete iSerialNumber;
       
   420                     iSerialNumber = NULL;
       
   421                     iSerialNumber = newSerialNumber.AllocL();
       
   422                     }
       
   423                 iWimInfoConstructed = ETrue;                
       
   424                 }
       
   425             }                       //temporalSerialNumber
       
   426         CleanupStack::PopAndDestroy( temporalSerialNumber );               
       
   427         }
       
   428     return status;
       
   429     }
       
   430 
       
   431 // -----------------------------------------------------------------------------
       
   432 // CWimSecModule::ConvertSerialNumberL()
       
   433 // Converts serialnumber. 
       
   434 // -----------------------------------------------------------------------------
       
   435 //
       
   436 void CWimSecModule::ConvertSerialNumberL( HBufC*& aSerialNumber )
       
   437     {
       
   438     _WIMTRACE ( _L( "CWimSecModule::ConvertSerialNumberL()" ) );
       
   439 
       
   440     TBuf<KVersionNumberLen> orginalVersionNumber;
       
   441     TBuf<KVersionNumberLen> newSerialNumber;
       
   442     TPtr ptr = aSerialNumber->Des();
       
   443     orginalVersionNumber.Copy( ptr );
       
   444     TInt len = orginalVersionNumber.Length(); 
       
   445     TInt i;
       
   446     TUint item;
       
   447     for ( i = 0; i<len; i++ )
       
   448         {
       
   449         item = orginalVersionNumber.operator[]( i ); 
       
   450         if ( item <= KSerialNumberMask )
       
   451             {
       
   452             //In this case we need to add an extra zero before actual value.
       
   453             newSerialNumber.AppendFormat( KZeroHex, 
       
   454                 TUint( orginalVersionNumber.operator[]( i ) ) );
       
   455             }
       
   456         else
       
   457             {
       
   458             //No need for further processing, simply append. 
       
   459             newSerialNumber.AppendFormat( KHex, 
       
   460                 TUint( orginalVersionNumber.operator[]( i ) ) );            
       
   461             }
       
   462         }
       
   463     delete iSerialNumber;
       
   464     iSerialNumber = NULL;
       
   465     iSerialNumber = newSerialNumber.AllocL();
       
   466     }
       
   467 
       
   468 // -----------------------------------------------------------------------------
       
   469 // CWimSecModule::GetPINModulesL( ) Asynchronous
       
   470 // Gets PIN references and creates new CWimPin objects.
       
   471 // -----------------------------------------------------------------------------
       
   472 //
       
   473 TInt CWimSecModule::GetPINModulesL( TRequestStatus& aStatus )
       
   474     {
       
   475     _WIMTRACE ( _L( "CWimSecModule::GetPINModulesL()" ) );
       
   476 
       
   477     TInt status = KErrNone;
       
   478     TUint pinCount= iClientSession->PINCount( iReference );
       
   479     iPinCount = pinCount;
       
   480     iPinInfoLst->Reset();
       
   481     
       
   482     if ( pinCount )
       
   483         {
       
   484         TPinAddress* pinLst = new( ELeave ) TPinAddress[pinCount];  
       
   485         CleanupStack::PushL( TCleanupItem( Cleanup, pinLst ) );
       
   486         
       
   487         status = iClientSession->PINRefs( iReference, iPinLstAddr, pinLst,
       
   488                                         ( TText8 )pinCount );
       
   489         if ( status == KErrNone ) 
       
   490             {
       
   491             if( iPinNRs == NULL )
       
   492 	            {
       
   493 	            iPinNRs = new( ELeave ) CArrayPtrFlat<CWimPin>( pinCount );	
       
   494 	            }
       
   495             else
       
   496 	            {
       
   497 	            iPinNRs->Reset();
       
   498 	            iPinNRs->ResizeL( pinCount );	
       
   499 	            }
       
   500             /* Construct PIN  modules */
       
   501             TUint8 index;
       
   502             for ( index = 0; index < pinCount; index++ )
       
   503                 {
       
   504                 CWimPin* pinModule = CWimPin::NewL( EWimPinNR, 
       
   505                                                     pinLst[index],
       
   506                                                     *iLabel );
       
   507                 CleanupStack::PushL( pinModule );
       
   508                 pinModule->SetClientSession( iClientSession );
       
   509                 iPinNRs->AppendL( pinModule );
       
   510                 CleanupStack::Pop( pinModule );/* Pop pinModule  */
       
   511                 }
       
   512               
       
   513             if(iPinInfoLst->Count() != pinCount )
       
   514                 {
       
   515             	iPinInfoLst->ResizeL( pinCount );
       
   516                 }
       
   517             
       
   518             iClientStatus = &aStatus;
       
   519             
       
   520             iStatus = KRequestPending;
       
   521             
       
   522             SetActive();
       
   523  
       
   524             iClientSession->PINsInfo( iReference, *iPinInfoLst,(TText8)pinCount, iStatus);
       
   525              
       
   526             }
       
   527         
       
   528         CleanupStack::PopAndDestroy( pinLst );/* pinLst */   
       
   529         
       
   530         }
       
   531     return status;
       
   532     }
       
   533 
       
   534 
       
   535 
       
   536 // -----------------------------------------------------------------------------
       
   537 // CWimSecModule::GetPINModulesL( ) Synchronous
       
   538 // Gets PIN references and creates new CWimPin objects.
       
   539 // -----------------------------------------------------------------------------
       
   540 //
       
   541 TInt CWimSecModule::GetPINModulesL()
       
   542     {
       
   543     _WIMTRACE ( _L( "CWimSecModule::GetPINModulesL()" ) );
       
   544 
       
   545     TInt status = KErrNone;
       
   546     TUint pinCount= iClientSession->PINCount( iReference );
       
   547     iPinCount = pinCount;
       
   548     iPinInfoLst->Reset();
       
   549     
       
   550     if ( pinCount )
       
   551         {
       
   552         TPinAddress* pinLst = new( ELeave ) TPinAddress[pinCount];  
       
   553         
       
   554         CleanupStack::PushL( TCleanupItem( Cleanup, pinLst ) );
       
   555         
       
   556         status = iClientSession->PINRefs( iReference, iPinLstAddr, pinLst,
       
   557                                         ( TText8 )pinCount );
       
   558         if ( status == KErrNone ) 
       
   559             {
       
   560             if( iPinNRs == NULL )
       
   561 	            {
       
   562 	            iPinNRs = new( ELeave ) CArrayPtrFlat<CWimPin>( pinCount );	
       
   563 	            }
       
   564             else
       
   565 	            {
       
   566 	            iPinNRs->Reset();
       
   567 	            iPinNRs->ResizeL( pinCount );	
       
   568 	            }
       
   569             /* Construct PIN  modules */
       
   570             TUint8 index;
       
   571             for ( index = 0; index < pinCount; index++ )
       
   572                 {
       
   573                 CWimPin* pinModule = CWimPin::NewL( EWimPinNR, 
       
   574                                                     pinLst[index],
       
   575                                                     *iLabel );
       
   576                 CleanupStack::PushL( pinModule );
       
   577                 pinModule->SetClientSession( iClientSession );
       
   578                 iPinNRs->AppendL( pinModule );
       
   579                 CleanupStack::Pop( pinModule );/* Pop pinModule  */
       
   580                 }
       
   581             
       
   582             if(iPinInfoLst->Count() != pinCount )
       
   583                 {
       
   584             	iPinInfoLst->ResizeL( pinCount );
       
   585                 }
       
   586           
       
   587           TInt err = iClientSession->PINsInfo( iReference, *iPinInfoLst,(TText8)pinCount );
       
   588            
       
   589           if( err != KErrNone )
       
   590              {
       
   591              User::LeaveIfError( KErrGeneral );	
       
   592              }
       
   593           
       
   594           for(TInt i=0; i<iPinCount; i++ )
       
   595 	          {
       
   596 	          ( *iPinNRs )[ i]->SetLabel( (*iPinInfoLst)[ i].iLabel );
       
   597 	    	  ( *iPinNRs )[ i]->SetPinStatus( (*iPinInfoLst)[ i].iStatus );
       
   598 	          ( *iPinNRs )[ i]->SetPinNumber( (*iPinInfoLst)[ i].iPinNumber );	
       
   599 	          }
       
   600             
       
   601             iPinNRsInit = ETrue;
       
   602             iPinInfoLst->Reset();    
       
   603             }
       
   604             
       
   605         CleanupStack::PopAndDestroy( pinLst );/* pinLst */
       
   606         }
       
   607     return status;
       
   608     }
       
   609 
       
   610 
       
   611 
       
   612 // -----------------------------------------------------------------------------
       
   613 // CWimSecModule::Cleanup()
       
   614 // Handles cleanup for an object which is not derived from CBase
       
   615 // -----------------------------------------------------------------------------
       
   616 //
       
   617 void CWimSecModule::Cleanup( TAny* aObject )
       
   618     {
       
   619     _WIMTRACE ( _L( "CWimSecModule::Cleanup()" ) );
       
   620     delete aObject;
       
   621     aObject = NULL;
       
   622     }
       
   623 
       
   624 // -----------------------------------------------------------------------------
       
   625 // CWimSecModule::SetClientSession()
       
   626 // Sets pointer RWimMgmt object to modifier iClientSession
       
   627 // -----------------------------------------------------------------------------
       
   628 //
       
   629 void CWimSecModule::SetClientSession( RWimMgmt* aClientSession )
       
   630     {
       
   631     _WIMTRACE ( _L( "CWimSecModule::SetClientSession()" ) );
       
   632     iClientSession = aClientSession;
       
   633     }
       
   634 
       
   635 
       
   636 // -----------------------------------------------------------------------------
       
   637 // CWimSecModule::RunL()
       
   638 // -----------------------------------------------------------------------------
       
   639 //
       
   640 void CWimSecModule::RunL()
       
   641     {
       
   642     _WIMTRACE ( _L( "CWimSecModule::RunL()" ) );
       
   643     
       
   644     if( iStatus.Int() != KErrNone )
       
   645         {
       
   646     	return;
       
   647         } 
       
   648         
       
   649     for(TInt i=0; i<iPinCount; i++ )
       
   650         {
       
   651     	( *iPinNRs )[ i]->SetLabel( (*iPinInfoLst)[ i].iLabel );
       
   652     	( *iPinNRs )[ i]->SetPinStatus( (*iPinInfoLst)[ i].iStatus );
       
   653         ( *iPinNRs )[ i]->SetPinNumber( (*iPinInfoLst)[ i].iPinNumber );
       
   654         }
       
   655     
       
   656     iPinNRsInit = ETrue;
       
   657      
       
   658     iPinInfoLst->Reset();    
       
   659     User::RequestComplete( iClientStatus, KErrNone );
       
   660     }
       
   661         
       
   662 // -----------------------------------------------------------------------------
       
   663 // CWimSecModule::DoCancel()
       
   664 // -----------------------------------------------------------------------------
       
   665 //
       
   666 void CWimSecModule::DoCancel()
       
   667     {
       
   668 	_WIMTRACE ( _L( "CWimSecModule::DoCancel() " ) );
       
   669 	User::RequestComplete( iClientStatus, KErrCancel );
       
   670     }
       
   671 
       
   672 // -----------------------------------------------------------------------------
       
   673 // CWimSecModule::RunError()
       
   674 // -----------------------------------------------------------------------------
       
   675 //
       
   676 TInt CWimSecModule::RunError( TInt aError )
       
   677     {
       
   678 	_WIMTRACE ( _L( "CWimSecModule::RunError() " ) );
       
   679 	User::RequestComplete( iClientStatus, aError );
       
   680 	return KErrNone;
       
   681     }
       
   682 
       
   683 // End of File