wim/Scard/inc/ScardMessageStack.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:  Smart card message stack.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CSCARDMESSAGESTACK_H
       
    21 #define CSCARDMESSAGESTACK_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include "ScardServerBase.h"
       
    25 #include "ScardClsv.h"
       
    26 #include "ScardCommandTimer.h"
       
    27 #include "ScardDefs.h"
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 class CScardCommandTimer;
       
    31 
       
    32 // CLASS DECLARATION
       
    33 
       
    34 /**
       
    35 *  Message stack.
       
    36 *  This class establishes a connection with a SC reader handler for a session. 
       
    37 *  Creates (if necessary) MScardReader objects, and determines when one of 
       
    38 *  them satisfies the parameters.
       
    39 *
       
    40 *  @lib Scard.lib
       
    41 *  @since Series60 2.1
       
    42 */
       
    43 class CScardMessageStack : public CBase
       
    44     {
       
    45     public:  // Constructors and destructor
       
    46 
       
    47         /**
       
    48         * Two-phased constructor.
       
    49         */
       
    50         static CScardMessageStack* NewL();
       
    51 
       
    52         /**
       
    53         * Destructor.
       
    54         */
       
    55         virtual ~CScardMessageStack();
       
    56     
       
    57     public: // New functions 
       
    58         
       
    59         /**
       
    60         * Cancel all messages waiting for service. Delete all others 
       
    61         * except the first one.
       
    62         * @param aReason Reason code for cancellation
       
    63         * @return void
       
    64         */
       
    65         void CancelAll( const TInt aReason );
       
    66         
       
    67         /**
       
    68         * Cancel all operations for this session ID.
       
    69         * @param aSessionID Session ID
       
    70         * @param aReason Reason code for cancellation
       
    71         * @return void
       
    72         */
       
    73         void CancelAll( const TInt aSessionID,
       
    74                         const TInt aReason );
       
    75 
       
    76         /**
       
    77         * Effectively the same as CancelAll(const TInt aReason), 
       
    78         * except that does not cancel OpenReader commands.
       
    79         * @return void
       
    80         */
       
    81         void CancelCardOperations();
       
    82 
       
    83         /**
       
    84         * Cancels the messages using the given timer.
       
    85         * @param aTimer Timer object
       
    86         * @return void
       
    87         */
       
    88         void CancelByTimeOut( const CScardCommandTimer* aTimer );
       
    89 
       
    90         /**
       
    91         * Puts the message to the top of the stack.
       
    92         * @param aMessage Message
       
    93         * @return Error code
       
    94         */
       
    95         TInt PushToTop( const TMessageHandle& aMessage );
       
    96 
       
    97         /**
       
    98         * Puts the message to the bottom of the stack.
       
    99         * @param aMessage Message
       
   100         * @return Error code
       
   101         */
       
   102         TInt PushToBottom( const TMessageHandle& aMessage );
       
   103 
       
   104         /**
       
   105         * Returns the topmost message from the stack.
       
   106         * @return Handle to topmost message
       
   107         */
       
   108         const TMessageHandle FromTop();
       
   109         
       
   110         /**
       
   111         * This function is called when a channel is freed. It gives priority
       
   112         * for applications who are waiting to reserve either this channel 
       
   113         * or any channel.
       
   114         * @param aChannel Channel
       
   115         * @return Handle to message
       
   116         */        
       
   117         const TMessageHandle NextReservation( const TInt8 aChannel );
       
   118 
       
   119         /**
       
   120         * Returns the message from given position in the stack.
       
   121         * @param aPosition Position from which we want the message
       
   122         * @return Handle to message
       
   123         */ 
       
   124         const TMessageHandle FromPositionL( const TInt aPosition );
       
   125 
       
   126         /**
       
   127         * Push message to given position in the stack.
       
   128         * @param aPosition Position to which we want to push the msg
       
   129         * @param aHandle Message handle
       
   130         * @return Handle to message
       
   131         */
       
   132         void PushToPositionL( const TInt aPosition,
       
   133                               TMessageHandle& aHandle );
       
   134 
       
   135         /**
       
   136         * Returns the number of messages in the stack.
       
   137         * @return Count of messagages in the stack
       
   138         */
       
   139         inline const TInt Count();
       
   140 
       
   141     private:
       
   142         
       
   143         /**
       
   144         * C++ default constructor.
       
   145         */
       
   146         CScardMessageStack();
       
   147         
       
   148         /**
       
   149         * By default Symbian 2nd phase constructor is private.
       
   150         */
       
   151         void ConstructL();
       
   152 
       
   153         /**
       
   154         * Cancel one message
       
   155         * @param aIndex Index of message
       
   156         * @param aReason Reason code for cancellation
       
   157         * @param aCancelTimer Do we want to cancel timer
       
   158         * @return void
       
   159         */
       
   160         inline void CancelOne( const TInt aIndex,
       
   161                                const TInt aReason, 
       
   162                                const TBool aCancelTimer = ETrue );
       
   163 
       
   164     private:    // Data
       
   165         // Array of messages. Owned.
       
   166         CArrayFixFlat<TMessageHandle>* iMessages;
       
   167     };
       
   168 
       
   169 #include "ScardMessageStack.inl"
       
   170 
       
   171 #endif      // CSCARDMESSAGESTACK_H
       
   172 
       
   173 // End of File