wim/WimServer/inc/WimApduImpl.h
changeset 0 164170e6151a
equal deleted inserted replaced
-1:000000000000 0:164170e6151a
       
     1 /*
       
     2 * Copyright (c) 2003 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:  APDU Interface between C and Symbian code. Implementations
       
    15 *               for WimApdu callbacks.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef CWIMAPDU_H
       
    21 #define CWIMAPDU_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include "Scard.h"
       
    25 #include "WimScardListener.h"
       
    26 
       
    27 
       
    28 // CONSTANTS
       
    29 const TInt KMaxApduLen     = 262;
       
    30 const TInt KMaxReaderCount = 8;
       
    31 
       
    32 const TInt KDefaulCloseChannelTimeout = 0;  //Timeout in microseconds
       
    33 const TUint8 KManageChannelIns        = 0x70;
       
    34 const TUint8 KManageChannelParamOpen  = 0x00;
       
    35 const TUint8 KManageChannelParamClose = 0x80;
       
    36 
       
    37 
       
    38 // FORWARD DECLARATIONS
       
    39 class CScardComm;
       
    40 class RScard;
       
    41 
       
    42 
       
    43 // CLASS DECLARATION
       
    44 
       
    45 /**
       
    46 *  WIM APDU interface.
       
    47 *  Interface between C and Symbian code. 
       
    48 *  Methods for sending and retrieve APDUs.
       
    49 *
       
    50 *  @since Series60 2.1
       
    51 */
       
    52 class CWimApdu : public CActive
       
    53     {
       
    54     public:  // Constructors and destructor
       
    55 
       
    56         /**
       
    57         * Destructor.
       
    58         */
       
    59          virtual ~CWimApdu();
       
    60 
       
    61         /**
       
    62         * Two-phased constructor.
       
    63         */
       
    64         static CWimApdu* NewL();
       
    65 
       
    66 
       
    67     public: // New functions
       
    68 
       
    69         /**
       
    70         * Opens a connection to a reader.
       
    71         * @param aUiReaderId Reader ID
       
    72         * @return status of the operation.
       
    73         */
       
    74         TUint8 Open( TUint8 aUiReaderId );
       
    75 
       
    76         /**
       
    77         * Closes a connection to a reader.
       
    78         * @param aUiReaderId Reader ID
       
    79         * @return status of the operation.
       
    80         */
       
    81         TUint8 Close( TUint8 aUiReaderId );
       
    82 
       
    83         /**
       
    84         * Sends an ISO 7816 APDU to reader.
       
    85         * @param aUiReaderId Reader ID
       
    86         * @param aApdu APDU to be sent
       
    87         * @param aUiApduLength legth of the APDU
       
    88         * @return status of the operation
       
    89         */
       
    90         TUint8 SendAPDU( TUint8  aUiReaderId,
       
    91                          TUint8* aApdu,
       
    92                          TUint16 aUiApduLength );
       
    93         /**
       
    94         * Cancel apdu sending
       
    95         */                 
       
    96         void CancelApduSending();                 
       
    97 
       
    98         /**
       
    99         * Gets a list of reader statusses.
       
   100         * @return status of the operation
       
   101         */
       
   102         TUint8 RequestListL();
       
   103 
       
   104         /**
       
   105         * Returns response APDU from latest SendAPDU call, 
       
   106         * does not return SW-bytes.
       
   107         * @return response APDU
       
   108         */
       
   109         TPtrC8 ResponseApdu() const;
       
   110 
       
   111         /**
       
   112         * Returns SW-bytes from latest SendApdu call.
       
   113         * @return SW bytes
       
   114         */
       
   115         TUint16 ResponseSW() const;
       
   116 
       
   117         /**
       
   118         * Returns a list of reader statusses from 
       
   119         * latest RequestList call.
       
   120         * @return reader status list
       
   121         */
       
   122         const TBuf8<KMaxReaderCount>& StatusList() const;
       
   123 
       
   124         /**
       
   125         * Returns the length of reader status list.
       
   126         * @return lenght of reader status list.
       
   127         */
       
   128         TUint8 StatusListLength() const;
       
   129 
       
   130     private:
       
   131 
       
   132         /**
       
   133         * C++ default constructor.
       
   134         */
       
   135         CWimApdu();
       
   136         
       
   137         /**
       
   138         * By default Symbian 2nd phase constructor is private.
       
   139         */
       
   140         void ConstructL();
       
   141 
       
   142         /**
       
   143         * From CActive. Stops ActiveSchedulerWait when got APDU response.
       
   144         * @return void
       
   145         */
       
   146         void RunL();
       
   147 
       
   148         /**
       
   149         * From CActive. Cancellation function
       
   150         * @return void
       
   151         */
       
   152         void DoCancel();
       
   153 
       
   154         /**
       
   155         * Wait until asynchronous call is completed
       
   156         * @return void
       
   157         */
       
   158         void SetActiveAndWait();
       
   159 
       
   160     private:    // Data
       
   161 
       
   162         // APDU responses are stored here. Owned.
       
   163         HBufC8*                           iResponseBuffer;
       
   164         // SW-bytes of the response.
       
   165         TUint16                           iResponseSW;
       
   166         // Statusses of the readers found
       
   167         TBuf8<KMaxReaderCount>            iReaderStatusses;
       
   168         // How many readers found.
       
   169         TUint8                            iReaderStatusLength;
       
   170         // Status of the response. Possible values in WimDefs.h.
       
   171         TUint8                            iResponseStatus;
       
   172         // Array containing CSardComm* object for each reader found. Owned.
       
   173         CArrayFixFlat<CScardComm*>*       iReaderComm;
       
   174         // Array of supported reader names
       
   175         CArrayFixFlat<TScardReaderName>*  iReaderNames;
       
   176         //Pointer to CScard
       
   177         RScard*                           iServer;
       
   178         // Array of Scard listeners
       
   179         CArrayPtrFlat<CWimScardListener>* iWimScardListenerArray;
       
   180         // Synchronous wait for async request
       
   181         CActiveSchedulerWait              iWait;
       
   182         
       
   183         TUint8                            iUiReaderId;
       
   184 
       
   185     };
       
   186 
       
   187 #endif      // CWIMAPDU_H
       
   188 
       
   189 // End of File