wim/SwimReader/inc/SwimReaderIF.h
changeset 0 164170e6151a
child 5 3b17fc5c9564
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:  SWIM reader interface
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CSWIMREADERIF_H
       
    21 #define CSWIMREADERIF_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include "ScardReader.h"
       
    25 #include "ScardNotifyObserver.h"
       
    26 
       
    27 //  CONSTANTS  
       
    28 const TUint8 KGetStatus = 0xf0;
       
    29 
       
    30 //  FORWARD DECLARATIONS
       
    31 class CSwimReader;
       
    32 class CSwimReaderLauncher;
       
    33 class CSwimSysAgentObserver;
       
    34 
       
    35 // CLASS DECLARATION
       
    36 
       
    37 /**
       
    38 *  Implements SwimReader interface class
       
    39 *  
       
    40 *
       
    41 *  @lib SwimReader.lib
       
    42 *  @since Series60 2.1
       
    43 */
       
    44 class CSwimReaderIF : public CActive, public MScardReader
       
    45     {
       
    46     public: // Constructors and destructor
       
    47        
       
    48         /**
       
    49         * Two-phased constructor.
       
    50         * @param aNotifyObserver Pointer to notify observer
       
    51         * @param aReaderID Reader ID
       
    52         * @param aLauncher Pointer to reader launcher
       
    53         */    
       
    54         static CSwimReaderIF* NewL( MScardNotifyObserver* aNotifyObserver,
       
    55                                     TReaderID aReaderID,
       
    56                                     CSwimReaderLauncher* aLauncher );
       
    57         
       
    58         /**
       
    59         * Destructor.
       
    60         */
       
    61         virtual ~CSwimReaderIF();
       
    62     
       
    63 
       
    64     public: // New functions
       
    65         
       
    66         /**
       
    67         * Cancel transmit
       
    68         * @return void
       
    69         */
       
    70         void CancelTransmit();
       
    71         
       
    72         /**
       
    73         * Close SwimReader IF
       
    74         * @return KErrNone
       
    75         */
       
    76         TInt Close();
       
    77         
       
    78         /**
       
    79         * Get the ATR bytes
       
    80         * @param aAtr ATR bytes
       
    81         * @return KScErrNotSupported
       
    82         */
       
    83         TInt GetATR( TScardATR& aAtr );
       
    84         
       
    85         /**
       
    86         * Get card status or presence bits according to aTag parameter
       
    87         * @param aStatus Clients request status
       
    88         * @param aTag Tag for request type
       
    89         * @param aValue Value of tag
       
    90         * @param aTimeout Timeout for GetCapabilities request
       
    91         * @return ETrue
       
    92         */        
       
    93         TBool GetCapabilities( TRequestStatus& aStatus,
       
    94                                const TInt32 aTag,
       
    95                                TPtr8& aValue,
       
    96                                const TInt32 aTimeout );
       
    97         
       
    98         /**
       
    99         * Notifies Scard Server about card event
       
   100         * @param aStatus TScardServiceStatus
       
   101         * @return void
       
   102         */
       
   103         void Notify( TScardServiceStatus aStatus );
       
   104         
       
   105         /**
       
   106         * Open connection to Etel server
       
   107         * @param  aStatus TRequestStatus
       
   108         * @return void 
       
   109         */            
       
   110         void Open( TRequestStatus& aStatus );
       
   111 
       
   112         /**
       
   113         * Send a CommandAPDU on a slot and return ResponseAPDU from slot
       
   114         * @param aStatus TRequestStatus
       
   115         * @param aCommandAPDU Command APDU
       
   116         * @param aResponceAPDU Response APDU
       
   117         * @param aTimeout Timeout
       
   118         * @return void
       
   119         */
       
   120         void TransmitToCard( TRequestStatus& aStatus,
       
   121                              const TPtrC8& aCommandAPDU,
       
   122                              TPtr8& aResponseAPDU,
       
   123                              const TInt32 aTimeout);
       
   124 
       
   125     private:
       
   126         
       
   127         /**
       
   128         * C++ default constructor.
       
   129         * @param aNotifyObserver Pointer to notify observer
       
   130         * @param aReaderID Reader ID
       
   131         * @param aLauncher Pointer to reader launcher
       
   132         */ 
       
   133         CSwimReaderIF( MScardNotifyObserver* aNotifyObserver, 
       
   134                        TReaderID aReaderID,
       
   135                        CSwimReaderLauncher* aLauncher );
       
   136         
       
   137         /**
       
   138         * By default Symbian 2nd phase constructor is private.
       
   139         */
       
   140         void ConstructL();
       
   141 
       
   142         /**
       
   143         * Handle open APDU
       
   144         * @return void
       
   145         */
       
   146         void HandleOpen();
       
   147 
       
   148         /**
       
   149         * From CActive, RunL
       
   150         * @return void
       
   151         */
       
   152         void RunL();
       
   153 
       
   154         /**
       
   155         * Cancel the asyncronous request
       
   156         * @return void
       
   157         */
       
   158         void DoCancel();
       
   159     
       
   160     private: // Data
       
   161         // Enumerator for reader IF phases
       
   162         enum TReaderIFPhase
       
   163             {
       
   164             EOpen,
       
   165             EGetATR,
       
   166             ETransmitToCard
       
   167             };
       
   168         // error code
       
   169         TInt                            iErr;
       
   170         // Pointer to client status. Not owned.
       
   171         TRequestStatus*                 iClientStatus;
       
   172         // Pointer to SwimReader object. Owned.
       
   173         CSwimReader*                    iFunctionalLevel;
       
   174         // Historical bytes
       
   175         TBuf8<KMaxATRHistoricalBytes>   iHistoricals;
       
   176         // Reader ID
       
   177         TReaderID                       iID;
       
   178         // Reader IF phase
       
   179         TReaderIFPhase                  iIFPhase;
       
   180         // Pointer to ReaderLauncher object. Not owned. 
       
   181         CSwimReaderLauncher*            iLauncher;
       
   182         // Pointer to NotifyObserver object
       
   183         MScardNotifyObserver*           iNotifyObserver;
       
   184          // Pointer to System Agent Observer. Owned.
       
   185         CSwimSysAgentObserver*          iSysAgentObserver;
       
   186         
       
   187     private:    // Friend classes
       
   188         friend class CSwimReaderLauncher;
       
   189     
       
   190     };
       
   191 
       
   192 #endif      // CSWIMREADERIF_H
       
   193 
       
   194 // End of file