wim/Scard/inc/ScardConnectionRegistry.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:  Keeps track, creates and destroys connector objects
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CSCARDCONNECTIONREGISTRY_H
       
    21 #define CSCARDCONNECTIONREGISTRY_H
       
    22 
       
    23 // INCLUDE FILES
       
    24 #include "ScardDefs.h"
       
    25 
       
    26 
       
    27 //FORWARD DECLARATIONS
       
    28 class CScardAccessControlRegistry;
       
    29 class CScardAccessControl;
       
    30 class CScardServer;
       
    31 class CScardConnector;
       
    32 class CScardSession;
       
    33 class MScardReader;
       
    34 
       
    35 
       
    36 // DATA TYPES
       
    37 struct TConnectionHandle
       
    38     {
       
    39     CScardConnector* iConnector;  // This is introduced in forward declarations
       
    40     CScardSession*   iClient;
       
    41     TConnectionHandle()
       
    42         :iConnector( NULL ), iClient( NULL )
       
    43         {}
       
    44     };
       
    45 
       
    46 // CLASS DECLARATION
       
    47 
       
    48 /**
       
    49 *  Keeps track, creates and destroys connector objects.
       
    50 *
       
    51 *  @lib Scard.lib
       
    52 *  @since Series60 2.1
       
    53 */
       
    54 class CScardConnectionRegistry : public CBase
       
    55     {
       
    56     public:  // Constructors and destructor
       
    57 
       
    58         /**
       
    59         * Two-phased constructor.
       
    60         * @param aServer Pointer to server object
       
    61         */
       
    62         static CScardConnectionRegistry* NewL( CScardServer* aServer );
       
    63         
       
    64         /**
       
    65         * Destructor.
       
    66         */
       
    67         virtual ~CScardConnectionRegistry();
       
    68     
       
    69     public: // New functions
       
    70         
       
    71         /**
       
    72         * Creates the connector and instructs it to connect.
       
    73         * @param aSession Pointer to session
       
    74         * @param aMessage Message
       
    75         * @return void
       
    76         */
       
    77         void ConnectToReaderL( CScardSession* aSession, 
       
    78                                const RMessage2& aMessage );
       
    79 
       
    80         /**
       
    81         * Finds the connector managing the session and instructs it cancel. 
       
    82         * Panics if the connector is not found.
       
    83         * @param aSession
       
    84         * @return void
       
    85         */
       
    86         void CancelConnection( CScardSession* aSession );
       
    87 
       
    88         /**
       
    89         * Connection completed.
       
    90         * @param aConnector Pointer to connector
       
    91         * @param aReaderID Reader ID
       
    92         * @param aErrorCode Error code that is returned in error
       
    93         * @return void
       
    94         */
       
    95         void ConnectDone( CScardConnector* aConnector, 
       
    96                           const TReaderID& aReaderID, 
       
    97                           const TInt& aErrorCode );
       
    98 
       
    99         /**
       
   100         * Removes connector from registry.
       
   101         * @param aConnector Pointer to connector to be removed
       
   102         * @return void
       
   103         */
       
   104         void RemoveConnector( CScardConnector* aConnector );
       
   105 
       
   106         /**
       
   107         * Return pointer to ScardServer object
       
   108         * @return Pointer to ScardServer object
       
   109         */
       
   110         CScardServer* Server() const;
       
   111 
       
   112         /**
       
   113         * Return connection handle
       
   114         * @param aLocation Index in iConnectors array
       
   115         * @return Connection handle
       
   116         */
       
   117         TConnectionHandle& Connection( TInt aLocation ) const;
       
   118 
       
   119     private:
       
   120         
       
   121         /**
       
   122         * C++ default constructor.
       
   123         */
       
   124         CScardConnectionRegistry();
       
   125 
       
   126         /**
       
   127         * By default Symbian 2nd phase constructor is private.
       
   128         * @param aServer Pointer to server object
       
   129         */
       
   130         void ConstructL( CScardServer* aServer );
       
   131 
       
   132     private:    // Data
       
   133         // Pointer to Scard Server. Not owned.
       
   134         CScardServer* iServer;
       
   135         // Array of connectors. Owned.
       
   136         CArrayFixFlat<TConnectionHandle>* iConnectors;
       
   137     };
       
   138 
       
   139 #endif      // CSCARDCONNECTIONREGISTRY_H
       
   140 
       
   141 // End of File