wim/Scard/inc/ScardChannelManager.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:  Handles individual channels on a singular SC 
       
    15 *               (which equals one SC reader handler) Can be queried
       
    16 *               for information about channels, controls traffic etc.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 #ifndef CSCARDCHANNELMANAGER_H
       
    23 #define CSCARDCHANNELMANAGER_H
       
    24 
       
    25 // INCLUDES
       
    26 #include "ScardServerBase.h"
       
    27 #include "ScardDefs.h"
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 class CScardAccessControl;
       
    31 class CScardMessageStack;
       
    32 class CScardCommandTimer;
       
    33 
       
    34 // CLASS DECLARATION
       
    35 
       
    36 /**
       
    37 *  Scard channel manager.
       
    38 *  Handles individual channels on a singular Smart card
       
    39 *  @lib Scard.lib
       
    40 *  @since Series60 2.1
       
    41 */
       
    42 class CScardChannelManager : public CBase
       
    43     {
       
    44     public:  // Constructors and destructor
       
    45         
       
    46         /**
       
    47         * Two-phased constructor.
       
    48         */
       
    49         static CScardChannelManager* NewL();
       
    50 
       
    51         /**
       
    52         * Destructor.
       
    53         */
       
    54         virtual ~CScardChannelManager();
       
    55 
       
    56     public: // New functions
       
    57 
       
    58         /**
       
    59         * Give the session the right to use the channel
       
    60         * @param aChannel Channel to be added
       
    61         * @param aSessionID Session ID
       
    62         * @return Always returns ETrue
       
    63         */
       
    64         TBool AddSessionToChannelL( const TInt8 aChannel, 
       
    65                                     const TInt aSessionID );
       
    66 
       
    67         /**
       
    68         * Remove session from the given channel
       
    69         * @param aChannel Channel
       
    70         * @param aSessionID Session ID to be removed
       
    71         * @return Always returns EFalse
       
    72         */
       
    73         TBool RemoveSessionL( const TInt8 aChannel, 
       
    74                               const TInt aSessionID );
       
    75 
       
    76         /**
       
    77         * Does the session have permission to the channel
       
    78         * @param aChannel Channel
       
    79         * @param aSessionID SessionID
       
    80         * @return ETrue if session is on channel, otherwise EFalse
       
    81         */
       
    82         TBool SessionIsOnChannel( const TInt8 aChannel, 
       
    83                                   const TInt aSessionID ) const;
       
    84 
       
    85         /**
       
    86         * This function returns an int16 that spesifies which channels have
       
    87         * been opened and which of them are reserved
       
    88         * @return Two-byte parameter telling:
       
    89         *   b0 - Channel 0 open (should always be set)
       
    90         *   b1 - Channel 0 reserved
       
    91         *   b2 - Channel 1 open
       
    92         *   b3 - Channel 1 reserved
       
    93         *   ...
       
    94         *   b7 - Channel 3 open
       
    95         *   b8 - Channel 3 reserved
       
    96         *                
       
    97         *   b9-b15 Maximum number of channels available (at the moment always 4)
       
    98         */
       
    99         TUint16 ChannelStatus();
       
   100 
       
   101         /**
       
   102         * Is the channel reserved? Return ID of session reserving the channel
       
   103         * @param aChannel Channel
       
   104         * @return Reserver session ID of the channel
       
   105         */
       
   106         TInt ChannelReservedL( const TInt8 aChannel ) const;
       
   107 
       
   108         /**
       
   109         * Remove the exclusive access from one channel.
       
   110         * @param aChannel Channel
       
   111         * @param aSessionID Session ID
       
   112         * @return void
       
   113         */
       
   114         void FreeChannelL( const TInt8 aChannel,
       
   115                            const TInt aSessionID );
       
   116 
       
   117         /**
       
   118         * Remove any exclusive accesses.
       
   119         * @param aChannel Channel
       
   120         * @return void
       
   121         */
       
   122         void FreeChannels( const TInt aSessionID );
       
   123 
       
   124         /**
       
   125         * Is the session on the channel, and is the channel number legal.
       
   126         * @param aChannel Channel
       
   127         * @param aSessionID SessionID
       
   128         * @return void
       
   129         */
       
   130         void ValidateChannelL( const TInt8 aChannel,
       
   131                                const TInt aSessionID );
       
   132 
       
   133         /**
       
   134         * Get the number of the next unreserved logical channel.
       
   135         * @param aChannel Channel
       
   136         * @return Number of next unreserved channel
       
   137         */
       
   138         TInt8 UnreservedLogicalChannel() const;
       
   139 
       
   140         /**
       
   141         * Has the channel been opened yet.
       
   142         * @param aChannel Channel
       
   143         * @return ETrue if channel already reserved, otherwise EFalse
       
   144         */
       
   145         TBool ChannelOpenedYet( const TInt8 aChannel );
       
   146 
       
   147         /**
       
   148         * Cancels the message.
       
   149         * @param aTimer Pointer to command timer
       
   150         * @return void
       
   151         */
       
   152         void CancelByTimeOut( CScardCommandTimer* aTimer );
       
   153 
       
   154         /**
       
   155         * Cancels all the messages for given session.
       
   156         * @param aSessionID SessionID
       
   157         * @return void
       
   158         */
       
   159         void CancelAll( const TInt aSessionID );
       
   160 
       
   161         /**
       
   162         * Puts message on bottom of message stack.
       
   163         * @param aMessage Message to be pushed to bottow of stack
       
   164         * @return void
       
   165         */
       
   166         void PushMessageToBottomL( const TMessageHandle& aMessage );
       
   167         
       
   168         /**
       
   169         * Puts message on top of message stack.
       
   170         * @param aMessage Message to be pushed
       
   171         * @return void
       
   172         */
       
   173         void PushMessageToTopL( const TMessageHandle& aMessage );
       
   174 
       
   175         /**
       
   176         * Get message from top of the message stack.
       
   177         * @return TMessageHandle
       
   178         */
       
   179         const TMessageHandle MessageFromTop();
       
   180         
       
   181         /**
       
   182         * Get next message
       
   183         * @return TMessageHandle
       
   184         */
       
   185         const TMessageHandle NextMessageL();
       
   186         
       
   187         /**
       
   188         * NextMessageFromFree
       
   189         * @param aChannel Channel
       
   190         * @return TMessageHandle
       
   191         */
       
   192         const TMessageHandle NextMessageFromFree( const TInt8 aChannel );
       
   193 
       
   194         /**
       
   195         * Handle channels when card is removed.
       
   196         * @return void
       
   197         */
       
   198         void CardRemoved();
       
   199     
       
   200     private:
       
   201         
       
   202         /**
       
   203         * C++ default constructor.
       
   204         */
       
   205         CScardChannelManager();
       
   206         
       
   207         /**
       
   208         * By default Symbian 2nd phase constructor is private.
       
   209         */
       
   210         void ConstructL();
       
   211 
       
   212     private:
       
   213         // The messages
       
   214         CScardMessageStack* iMessageStack;
       
   215     
       
   216         // The sessions that are joined/channel
       
   217         CArrayPtrFlat< CArrayFixFlat<TInt> >* iChannels;
       
   218 
       
   219         //  IDs of sessions that are currently reserving the channels
       
   220         TInt iReserverID[KMaxChannels];
       
   221     };
       
   222 
       
   223 #endif      // CSCARDCHANNELMANAGER_H
       
   224 
       
   225 // End of File