wim/WimClient/inc/WimSecModule.h
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 
       
    20 #ifndef WIMSECMODULE_H
       
    21 #define WIMSECMODULE_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include "WimClsv.h"
       
    25 #include <e32base.h>
       
    26 
       
    27 // FORWARD DECLARATIONS
       
    28 class CWimPin;
       
    29 class RWimMgmt;
       
    30 
       
    31 
       
    32 // CLASS DECLARATION
       
    33 
       
    34 /**
       
    35 *  API for managing WIM Security Module.
       
    36 *  Provides methods to manage one WIM Security Module:
       
    37 *  check statuses, change settings, use functionality 
       
    38 *  provide it and list PINs.
       
    39 *
       
    40 *  @lib WimClient
       
    41 *  @since Series 60 2.1
       
    42 */
       
    43 class CWimSecModule: public CActive
       
    44     {
       
    45     public:  // Constructors and destructor
       
    46                     
       
    47         /**
       
    48         * Two-phased constructor.
       
    49         * @param aWimAddr
       
    50         */
       
    51         IMPORT_C static CWimSecModule* NewL( TWimAddress aWimAddr ); 
       
    52         
       
    53         /**
       
    54         * Destructor.
       
    55         */
       
    56         IMPORT_C virtual ~CWimSecModule();
       
    57 
       
    58     public: // New functions
       
    59             
       
    60         /**
       
    61         * Checks is WIM already open.
       
    62         * @return ETrue if WIM's is open (=PIN-G verified)
       
    63         *         else EFalse  
       
    64         */
       
    65         IMPORT_C TBool IsOpen(); 
       
    66 
       
    67         /**
       
    68         * Returns the time which is set as WIM closeout time
       
    69         * @return Timeout in minutes
       
    70         */
       
    71         IMPORT_C TInt CloseAfter();
       
    72 
       
    73         /**
       
    74         * Returns the timeout which tells how 
       
    75         * long WIM Security Module will be open 
       
    76         * after it is opened.
       
    77         * @return Timeout in minutes
       
    78         */
       
    79         IMPORT_C TInt TimeRemaining();
       
    80 
       
    81         
       
    82         /**
       
    83         * Returns WIM Security Module's keys' PIN-NR objects in array.
       
    84         * @param aPinNRs -Array of pointers to CWimPin objects which
       
    85         *                are initialized as PIN-NR. (IN/OUT)
       
    86         * @return TInt  -Error code
       
    87         */
       
    88         IMPORT_C TInt PinNrEntriesL( const CArrayPtrFlat<CWimPin>*& aPinNRs, TRequestStatus& aStatus  );
       
    89      
       
    90         /**
       
    91         * Returns WIM Security Module's keys' PIN-NR objects in array.
       
    92         * @param aPinNRs -Array of pointers to CWimPin objects which
       
    93         *                are initialized as PIN-NR. (IN/OUT)
       
    94         * @return TInt  -Error code
       
    95         */
       
    96         IMPORT_C TInt PinNrEntriesL( const CArrayPtrFlat<CWimPin>*& aPinNRs );
       
    97         
       
    98         /**
       
    99         * Returns WIM's version. This will return KErrNone according to PKC15. 
       
   100         * @return Pointer descriptor containing version.
       
   101         */
       
   102         IMPORT_C const TDesC& Version();
       
   103 
       
   104         /**
       
   105         * Returns WIM's label.
       
   106         * @return Pointer descriptor containing label.
       
   107         */
       
   108         IMPORT_C TPtrC Label();
       
   109 
       
   110         /**
       
   111         * Returns WIM's manufacturer.
       
   112         * @return Pointer descriptor containing manufacturer.
       
   113         */
       
   114         IMPORT_C const TDesC& Manufacturer();
       
   115 
       
   116         /**
       
   117         * Returns WIM's serial number which identifies it.
       
   118         * @return Pointer descriptor containing serial number
       
   119         */
       
   120         IMPORT_C const TDesC& SerialNumber();
       
   121 
       
   122         /**
       
   123         * Closes the parts of WIM which is opened with PIN-G.
       
   124         * @return TInt Error code
       
   125         */
       
   126         IMPORT_C TInt Close();
       
   127 
       
   128         /**
       
   129         * Sets the timeout which defines the time after WIM 
       
   130         * is automatically closed.
       
   131         * @param aTimeout, timeout in minutes.
       
   132         * @return void
       
   133         */
       
   134         IMPORT_C void SetCloseAfter( const TUint aTimeout );
       
   135 
       
   136 
       
   137         /**
       
   138         * Notifies the client when the token has been removed.
       
   139         * @param aStatus -TRequestStatus
       
   140         * @return void
       
   141         */
       
   142         IMPORT_C void NotifyOnRemoval( TRequestStatus& aStatus );
       
   143 
       
   144         /**
       
   145         * Cancels the notifyOnRemoval request.
       
   146         * @return void
       
   147         */
       
   148         IMPORT_C void CancelNotifyOnRemoval();
       
   149 
       
   150         /**
       
   151         * Returns the number of the slot, where current token is connected
       
   152         * @return TUint8
       
   153         */
       
   154         IMPORT_C TUint8 TokenNumber();
       
   155 
       
   156         /**
       
   157         * Sets pointer RWimMgmt object to modifier iClientSession
       
   158         * @param aClientSession Client session
       
   159         * @return void
       
   160         */
       
   161         void SetClientSession( RWimMgmt* aClientSession );
       
   162 
       
   163 
       
   164     private:
       
   165 
       
   166         /**
       
   167         * C++ constructor.
       
   168         * @param aWimAddr
       
   169         */
       
   170         CWimSecModule( TWimAddress aWimAddr );
       
   171 
       
   172         /**
       
   173         * By default EPOC constructor is private.
       
   174         */
       
   175         void ConstructL();
       
   176 
       
   177 
       
   178         /**
       
   179         * Gets label,manufacturer,serialnumber and the number of 
       
   180         * the slot where card is.
       
   181         * @return TInt
       
   182         */
       
   183         TInt GetWIMInfoL(); 
       
   184 
       
   185         /** 
       
   186         * Handles cleanup for an object which is not derived from CBase
       
   187         * @param aObject -object to be cleaned up
       
   188         */
       
   189         static void Cleanup( TAny* aObject );
       
   190 
       
   191         /** 
       
   192         * Converts serialnumber to 8-bit form. Conversion reads
       
   193         * memory area from orginal serialnumber and captures its significant
       
   194         * bits to a new 8-bit -modifier. 
       
   195         * @param aSerialNumber -number to be converted
       
   196         * @return void
       
   197         */
       
   198         void ConvertSerialNumberL( HBufC*& aSerialNumber );
       
   199         
       
   200     private:  
       
   201         
       
   202         /**
       
   203         * Gets PIN references and creates new CWimPin objects
       
   204         * @return TInt  -Error code
       
   205         */
       
   206         TInt GetPINModulesL( TRequestStatus& aStatus );
       
   207         
       
   208         /**
       
   209         * Gets PIN references and creates new CWimPin objects
       
   210         * @return TInt  -Error code
       
   211         */
       
   212         TInt GetPINModulesL();
       
   213         
       
   214     private: //from CActive
       
   215         
       
   216         /**
       
   217         * Different phases are handled here.
       
   218         * @return void
       
   219         */
       
   220         void RunL();
       
   221         
       
   222         /**
       
   223         * Cancellation function
       
   224         * Deallocates member variables and completes client status with
       
   225         * KErrCancel error code.
       
   226         * @return void
       
   227         */
       
   228         void DoCancel();
       
   229 
       
   230         /**
       
   231         * The active scheduler calls this function if this active 
       
   232         * object's RunL() function leaves. 
       
   233         * Handles neccessary cleanup and completes request with
       
   234         * received error code.
       
   235         * @param aError -Error code which caused this event
       
   236         * @return TInt  -Error code to active scheduler, is always KErrNone.
       
   237         */ 
       
   238         TInt RunError( TInt aError );    
       
   239   
       
   240     private: 
       
   241 
       
   242         // Reference to WIM. 
       
   243         TWimAddress             iReference;  
       
   244         // Array of pointers to PIN-NRs.This class owns this and
       
   245         // this is valid as long as CWimSecModule is valid.
       
   246         CArrayPtrFlat<CWimPin>* iPinNRs; 
       
   247         //Contains tokens label.Owned
       
   248         HBufC*                  iLabel;
       
   249         //Contains tokens manufacturer.Owned
       
   250         HBufC*                  iManufacturer;
       
   251         //Contains tokens SerialNumber.Owned
       
   252         HBufC*                  iSerialNumber;
       
   253         //Contains tokens version. Owned
       
   254         HBufC*                  iVersion;
       
   255         //The "slot" where WIM-card is inserted
       
   256         TUint8                  iReader;        
       
   257         //pointer to RWIMMgmt. Owned by CWimSecModuleMgr.
       
   258         RWimMgmt*               iClientSession;
       
   259         //Boolean value 
       
   260         TBool                   iWimInfoConstructed;
       
   261         //TUint32, reference to pinlist.
       
   262         TUint32                 iPinLstAddr;
       
   263         //TUint32, reference to ping.
       
   264         TPinAddress             iRefPing;
       
   265         
       
   266         TWimPinStruct*          iPinStructLst; //Owned
       
   267         
       
   268         TRequestStatus*         iClientStatus;
       
   269         
       
   270         TUint                   iPinCount;
       
   271         
       
   272         CArrayFixFlat<TWimPinStruct>* iPinInfoLst; //Owned
       
   273         //ETrue if iPinNRs is initialized
       
   274         TBool                   iPinNRsInit;
       
   275 
       
   276     };
       
   277 
       
   278 #endif      // WIMSECMODULE_H   
       
   279             
       
   280 // End of File