wim/inc/ScardComm.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:  Core class for all Smart Card aware applications to use when 
       
    15 *                communicating with the card.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #ifndef CSCARDCOMM_H
       
    22 #define CSCARDCOMM_H
       
    23 
       
    24 //  INCLUDES
       
    25 #include "ScardConnectionRequirement.h"
       
    26 
       
    27 
       
    28 // FORWARD DECLARATIONS
       
    29 class RScard;
       
    30 
       
    31 // CLASS DECLARATION
       
    32 
       
    33 /**
       
    34 *  Core class for card communication.
       
    35 *  This is the core class for all SC aware applications to use when 
       
    36 *  communicating with the card. All objects of this class are 
       
    37 *  connected to a reader, and the reader's name must be supplied as a 
       
    38 *  parameter when constructing objects of this class
       
    39 *
       
    40 *  @lib Scard.lib
       
    41 *  @since Series60 2.1
       
    42 */
       
    43 class CScardComm : public CBase
       
    44     {
       
    45     public:  // Constructors and destructor
       
    46         
       
    47         /**
       
    48         * Two-phased constructor.
       
    49         * @param aScard The connection to server. 
       
    50         *        The RScard object must not have any other CScardComm objects
       
    51         *        attached to it.
       
    52         * @param aRequirement Parameters to the connection
       
    53         * @param aReaderName This is set to contain the name of the 
       
    54         *        reader that was contacted when a connection is established
       
    55         * @param aStatus This status is signaled when connection has been made
       
    56         * @param aTimeOut The timeout in microseconds
       
    57         * @return Pointer to CScardComm object
       
    58         */
       
    59         IMPORT_C static CScardComm* NewL(
       
    60             RScard* aScard, 
       
    61             TScardConnectionRequirement& aRequirement,
       
    62             TScardReaderName& aReaderName,
       
    63             TRequestStatus& aStatus, 
       
    64             const TInt32 aTimeOut = 0 );
       
    65         
       
    66         /**
       
    67         * Destructor.
       
    68         */
       
    69         IMPORT_C virtual ~CScardComm();
       
    70 
       
    71     public: // New functions
       
    72         
       
    73         /**
       
    74         * Returns the RScard object contained within this object.
       
    75         * @return Pointer to RScard object
       
    76         */
       
    77         IMPORT_C RScard* Scard() const;
       
    78 
       
    79         /**
       
    80         * This function fetches the answer-to-reset bytes of the SC 
       
    81         * currently in the card reader. If an error occurs during the 
       
    82         * operation, the  length of the atr bytes is set to zero. Currently
       
    83         * leaves with KErrNotSupported
       
    84         * @param aATR ATR-bytes
       
    85         * @return void
       
    86         */
       
    87         IMPORT_C void GetATRL( TScardATR& aATR ) const;
       
    88 
       
    89         /**
       
    90         * Get proprietary parameters from the reader handler.
       
    91         * @param aTag parameter wanted (see scardbase.h)
       
    92         * @param aValue value of desired parameter
       
    93         * @param aTimeOut timeout in microseconds
       
    94         * @return void
       
    95         */
       
    96         IMPORT_C void GetCapabilitiesL( const TInt32 aTag,
       
    97                                         TDes8& aValue, 
       
    98                                         const TInt32 aTimeOut = 0 ) const;
       
    99 
       
   100         /**
       
   101         * This function is the basic transmission function. It takes a
       
   102         * 8-bit command data of unspecified length and transmits it to 
       
   103         * the reader handler. The reader handler will pass it on to the 
       
   104         * card, and place the response in the supplied response buffer 
       
   105         * (also of undefined length). The buffer must be sufficiently 
       
   106         * big to accomodate the response, otherwise the calling thread 
       
   107         * will be panicked.
       
   108         * @param aCommand This descriptor holds the command sent to the 
       
   109         *        card. The length of the descriptor must match the data length
       
   110         *        of the command.
       
   111         * @param aResponse The response from the SC is copied here.
       
   112         * @param aStatus Signaled when the operation is finished.
       
   113         * @param aTimeOut Timeout in microseconds.
       
   114         * @param aChannel The logical channel this command will be executed in.
       
   115         * @return void
       
   116         */
       
   117         IMPORT_C void TransmitToCard( const TDesC8& aCommand, 
       
   118                                       TDes8& aResponse,
       
   119                                       TRequestStatus& aStatus,
       
   120                                       const TInt32 aTimeOut = 0, 
       
   121                                       const TInt8 aChannel = 0) const;
       
   122 
       
   123         /**
       
   124         * This function will cancel any transmissions and other 
       
   125         * operations this object has currently pending within the 
       
   126         * server. If the object has an active transaction reservation, 
       
   127         * this will also be cancelled. All operations sent before this 
       
   128         * command will terminate with error code KScErrCancelled.
       
   129         * @return void
       
   130         */
       
   131         IMPORT_C void CancelTransmit() const;
       
   132 
       
   133         /**
       
   134         * Channel management function.
       
   135         * @param aCommand Channel operation.
       
   136         * @param aArgument
       
   137         * @param aResponseBuffer Buffer for response.
       
   138         * @param aStatus Signaled when the operation is finished.
       
   139         * @param aTimeOut Timeout in microseconds.
       
   140         * @return void
       
   141         */
       
   142         IMPORT_C void ManageChannel( const TScChannelManagement aCommand, 
       
   143                                      const TInt8 aArgument,
       
   144                                      TDes8& aResponseBuffer,
       
   145                                      TRequestStatus& aStatus,
       
   146                                      const TInt32 aTimeOut ) const;
       
   147 
       
   148     private:
       
   149 
       
   150         /**
       
   151         * C++ default constructor.
       
   152         * @param aScard Pointer to RScard object
       
   153         */
       
   154         CScardComm( RScard* aScard );
       
   155 
       
   156 
       
   157         /**
       
   158         * By default Symbian OS constructor is private.
       
   159         */
       
   160         void ConstructL( TScardConnectionRequirement& aRequirement,
       
   161                          TScardReaderName& aReaderName, 
       
   162                          TRequestStatus& aStatus, 
       
   163                          const TInt32 aTimeOut );
       
   164 
       
   165         /**
       
   166         * Disconnect from reader
       
   167         * @return void
       
   168         */
       
   169         void DisconnectFromReader() const;
       
   170     
       
   171     private:    // Data
       
   172         // Pointer to Scard object. Not owned. 
       
   173         RScard* iScard;
       
   174     };
       
   175 
       
   176 #endif      // CSCARDCOMM_H   
       
   177             
       
   178 // End of File