wim/inc/WimPin.h
changeset 0 164170e6151a
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 PIN
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef WIMPIN_H
       
    20 #define WIMPIN_H
       
    21 
       
    22 
       
    23 //  INCLUDES
       
    24 #include "WimClsv.h"
       
    25 #include <e32base.h>
       
    26 #include <secdlg.h> 
       
    27 
       
    28 
       
    29 class RWimMgmt;
       
    30 
       
    31 /**
       
    32 *  API for managing PIN.
       
    33 *  This API provides methods to manage PIN: check statuses and
       
    34 *  change settings.
       
    35 *
       
    36 *  @lib WimClient
       
    37 *  @since Series 60 2.6
       
    38 */
       
    39 class CWimPin: public CActive
       
    40     {
       
    41     public:  
       
    42         
       
    43         /**
       
    44         * Two-phased constructor.
       
    45         * @param aPin       -the type of Pin
       
    46         * @param aPinAddr   -Reference to Pin structure
       
    47         * @param aTokenLabel -the name of the token
       
    48         */
       
    49         IMPORT_C static CWimPin* NewL( TWimPin aPin,  
       
    50                                        const TPinAddress aPinAddr,
       
    51                                        TDesC& aTokenLabel );  
       
    52 
       
    53         /**
       
    54         * Destructor.
       
    55         */
       
    56         IMPORT_C virtual ~CWimPin();
       
    57 
       
    58         
       
    59     public: // New functions
       
    60 
       
    61         /**
       
    62         * Enables Pin query of the Pin.
       
    63         * The PinStatus() function should be called before 
       
    64         * calling this function to make sure the status of
       
    65         * pin
       
    66         * @param aStatus -Caller's status.
       
    67         * @return void
       
    68         */        
       
    69         IMPORT_C void EnablePinQuery( TRequestStatus& aStatus );
       
    70         
       
    71         /**
       
    72         * Cancel enables Pin query of the Pin.
       
    73         * @return void
       
    74         */  
       
    75         IMPORT_C void CancelEnablePinQuery();
       
    76         
       
    77         /**
       
    78         * Disables Pin query of the Pin.
       
    79         * The PinStatus() function should be called before 
       
    80         * calling this function to make sure the status of
       
    81         * pin
       
    82         * @param aStatus -Caller's status.
       
    83         * @return void
       
    84         */                
       
    85         IMPORT_C void DisablePinQuery( TRequestStatus& aStatus );
       
    86         
       
    87         /**
       
    88         * Cancel disables Pin query of the Pin.
       
    89         * @return void
       
    90         */  
       
    91         IMPORT_C void CancelDisablePinQuery();
       
    92         
       
    93         /**
       
    94         * Changes Pin.
       
    95         * The PinStatus() function should be called before 
       
    96         * calling this function to make sure the status of
       
    97         * pin
       
    98         * @param aStatus -Caller's status
       
    99         * @return void
       
   100         */        
       
   101         IMPORT_C void ChangePin( TRequestStatus& aStatus );
       
   102         
       
   103         /**
       
   104         * Cancel changes Pin.
       
   105         * @return void
       
   106         */ 
       
   107         IMPORT_C void CancelChangePin();
       
   108         
       
   109         /**
       
   110         * Unblocks Pin
       
   111         * The PinStatus() function should be called before 
       
   112         * calling this function to make sure the status of
       
   113         * pin
       
   114         * @param aStatus -Caller's status
       
   115         * @return void
       
   116         */        
       
   117         IMPORT_C void UnblockPin( TRequestStatus& aStatus );
       
   118         
       
   119         /**
       
   120         * Cancel unblocks Pin
       
   121         * @return void
       
   122         */  
       
   123         IMPORT_C void CancelUnblockPin();
       
   124         
       
   125         /**
       
   126         * Verifies the enterd Pin -request.
       
   127         * The PinStatus() function should be called before 
       
   128         * calling this function to make sure the status of
       
   129         * pin
       
   130         * @param aStatus -Caller's status 
       
   131         * @return void
       
   132         */        
       
   133         IMPORT_C void VerifyPin( TRequestStatus& aStatus );
       
   134         
       
   135         /**
       
   136         * Cancel verifies the enterd Pin -request.
       
   137         * @return void
       
   138         */ 
       
   139         IMPORT_C void CancelVerifyPin();
       
   140         
       
   141         /**
       
   142         * Returns PIN's label.
       
   143         * @return Pointer descriptor containing label.
       
   144         */
       
   145         IMPORT_C TPtrC Label();
       
   146    
       
   147         /**
       
   148         * Returns the status of Pin.
       
   149         * Variations are: WIMI_PF_Enabled           
       
   150         *                 WIMI_PF_ChangeDisabled    
       
   151         *                 WIMI_PF_UnblockDisabled   
       
   152         *                 WIMI_PF_DisableAllowed
       
   153         * @return iStatus -status of Pin
       
   154         */        
       
   155         IMPORT_C TWimPinStatus PinStatus();
       
   156 
       
   157         /** 
       
   158         * Returns the number of the pin. It is a number, which 
       
   159         * identifies pin object in the Wim -card. Pin number
       
   160         * can be eg. 0,1,2....
       
   161         * @return TUint8    -PinNumber
       
   162         */
       
   163         IMPORT_C TUint8 PinNumber();
       
   164 
       
   165     public:
       
   166 
       
   167         /*
       
   168         * Sets RWimMgmt* pointer to iClientSession
       
   169         * @param aClientSession
       
   170         * @return void
       
   171         */
       
   172         void SetClientSession( RWimMgmt* aClientSession );
       
   173         
       
   174         /*
       
   175         * Sets Label 
       
   176         * return void
       
   177         */
       
   178         void SetLabel( TBuf<KLabelLen>& aLabel );
       
   179         
       
   180         /*
       
   181         * Sets PinStatus 
       
   182         * return void
       
   183         */
       
   184     	  void SetPinStatus( TWimPinStatus& aStatus );
       
   185     	  
       
   186     	  /*
       
   187         * Sets Pin Number 
       
   188         * return void
       
   189         */
       
   190     	  void SetPinNumber( TUint8& aPinNumber );
       
   191     
       
   192     private:
       
   193 
       
   194         /** 
       
   195         * Constructs pinparams struct.
       
   196         * @param aPinParams -params to be constructed.
       
   197         * @return TPINParams
       
   198         */
       
   199         void PinParams( TPINParams& aPinParams );
       
   200 
       
   201         /**
       
   202         * Checks is Pin changeable.
       
   203         * @return ETrue if PIN is changeable else returns EFalse.
       
   204         */
       
   205         TBool PinChangeable();
       
   206 
       
   207         /**
       
   208         * C++ constructor.
       
   209         * @param aPin   -the type of the pin
       
   210         * @param aPinAddr -Reference to Pin structure.
       
   211         */
       
   212         CWimPin( TWimPin aPin, TPinAddress aPinAddr );
       
   213 
       
   214         /**
       
   215         * Default constructor is private.
       
   216         * @param aTokenLabel -Label of the token
       
   217         * @return void
       
   218         */
       
   219         void ConstructL( const TDesC& aTokenLabel );
       
   220 
       
   221         /*
       
   222         * Get Pin Info. Initializes member variables.
       
   223         * @return void
       
   224         */
       
   225         void PinInfo( TRequestStatus& aStatus );
       
   226 
       
   227         /**
       
   228         * Sets own iStatus to KRequestPending, and signals it 
       
   229         * with User::RequestComplete() -request. This gives change 
       
   230         * to activescheduler to run other active objects. After a quick
       
   231         * visit in activescheduler, signal returns to RunL() and starts next
       
   232         * phase of operation. 
       
   233         * @return void
       
   234         */
       
   235         void SignalOwnStatusAndComplete();
       
   236 
       
   237 
       
   238     private: //From CActive
       
   239 
       
   240         /**
       
   241         * Different phases are handled here.
       
   242         * @return void
       
   243         */
       
   244         void RunL();
       
   245 
       
   246         /**
       
   247         * Cancellation function
       
   248         * Not allowed to cancel
       
   249         * @return void
       
   250         */       
       
   251         void DoCancel();
       
   252 
       
   253         /**
       
   254         * The active scheduler calls this function if this active 
       
   255         * object's RunL() function leaves. 
       
   256         * Handles necessary cleanup and completes request with
       
   257         * received error code.
       
   258         * @param aError -The error code which caused this function call.
       
   259         * @return TInt  -Error code to activescheduler, is always KErrNone.
       
   260         */ 
       
   261         TInt RunError( TInt aError );
       
   262 
       
   263     private:
       
   264         
       
   265         //Ten different phases for PIN handling
       
   266         enum TPinPhase
       
   267             {
       
   268             EEnablePinQueryStart,
       
   269             EEnablePinQueryEnd,
       
   270             EDisablePinQueryStart,
       
   271             EDisablePinQueryEnd,
       
   272             EChangePinStart,
       
   273             EChangePinEnd,
       
   274             EUnblockPinStart,
       
   275             EUnblockPinEnd,
       
   276             EVerifyPinStart,
       
   277             EVerifyPinEnd,
       
   278             EUpdatePinStatus,
       
   279             EUpdatePinStatusDone
       
   280             };
       
   281 
       
   282         //Used to handle different phases in RunL()
       
   283         TPinPhase iPhase;
       
   284         
       
   285         TPinPhase iCurrentPhase;
       
   286         
       
   287     private:    
       
   288 
       
   289         //Client status is stored here while operation
       
   290         //on the server side is done.        
       
   291         TRequestStatus*             iClientStatus;
       
   292         // Reference to PIN.
       
   293         const TPinAddress           iReference; 
       
   294         //Pin type: Pin-G or PinNR
       
   295         TWimPin                     iPinType;
       
   296         //Holds label. Owned
       
   297         HBufC*                      iLabel;
       
   298         //Holds tokenlabel.Owned.
       
   299         HBufC*                      iTokenLabel;
       
   300         //Holds Pin-status
       
   301         TWimPinStatus               iPinStatus;
       
   302         //pointer to clientSession. Owned by CWimSecModuleMgr.
       
   303         RWimMgmt*                   iClientSession;
       
   304         //Number that identifies Pin in the Wim. Its a running number 0,1,2..
       
   305         TUint8                      iPinNumber;
       
   306         //Struct for PIN parameters
       
   307         TPINParams                  iPinParams;
       
   308         //Struct for enable/disable information
       
   309         TPINStateRequest            iPinStateRequest;
       
   310         //To store the status value from wimserver
       
   311         TInt                        iReceivedStatus;
       
   312         
       
   313         TWimPinStruct               iPinStruct;
       
   314 
       
   315     };
       
   316 
       
   317 #endif       
       
   318 // End of File