wim/inc/ScardListener.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:  Listens for smard card events
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CSCARDLISTENER_H
       
    21 #define CSCARDLISTENER_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include "ScardDefs.h"
       
    25 
       
    26 // FORWARD DECLARATIONS
       
    27 class RScard;
       
    28 
       
    29 // CLASS DECLARATION
       
    30 
       
    31 /**
       
    32 *  A base class for listening card events.
       
    33 *  This class is a virtual base class used to transmit card events from 
       
    34 *  a spesific reader to the terminal, and it intended for use in all 
       
    35 *  applications that need to use smart cards. When an event occurs, 
       
    36 *  it is reported to the listener, and the listener will launch the 
       
    37 *  ProcessEvent function. This function is pure virtual, so a user of 
       
    38 *  this class must derive a concrete class from CScardListener, 
       
    39 *  and give an implementation to the ProcessEvent function.
       
    40 */
       
    41 class CScardListener : public CActive
       
    42     { 
       
    43     public: // New functions
       
    44         
       
    45         /**
       
    46         * This function initiates the first request from this listener 
       
    47         * to the server to be notified of card events from the spesified 
       
    48         * reader. After this the listener will listen and report all 
       
    49         * card events from the reader.
       
    50         * @param aReaderName Name of the reader
       
    51         * @return an error code (KErrNone if succesful)
       
    52         */
       
    53         IMPORT_C TInt ListenCardEvents( const TScardReaderName& aReaderName );
       
    54 
       
    55     protected:  // New functions
       
    56         
       
    57         /**
       
    58         * Construction.
       
    59         * @param aScard pointer to scard class
       
    60         * @return void
       
    61         */
       
    62         IMPORT_C CScardListener( RScard* aScard );
       
    63 
       
    64         /**
       
    65         * Destruction.
       
    66         */
       
    67         IMPORT_C virtual ~CScardListener();
       
    68 
       
    69         /**
       
    70         * This function is called from RunL() and it is pure virtual, 
       
    71         * so an implementation must be provided by derived classes to 
       
    72         * handle the received events.
       
    73         * @param aEvent
       
    74         */
       
    75         virtual void ProcessEvent( const TScardServiceStatus aEvent) = 0;
       
    76 
       
    77         
       
    78     protected:  // Functions from base classes
       
    79         
       
    80         /**
       
    81         * From CActive Cancel request
       
    82         */
       
    83         IMPORT_C void DoCancel();
       
    84 
       
    85         /**
       
    86         * From CActive Service completed request
       
    87         */
       
    88         IMPORT_C void RunL();
       
    89 
       
    90     
       
    91     private:
       
    92 
       
    93         /**
       
    94         * Tell the server to notify this object of card events.
       
    95         * @param aStatus Request status
       
    96         * @param aReaderName Name of the reader
       
    97         * @return an error code (KErrNone if succesful)
       
    98         */
       
    99         TInt NotifyChange( TRequestStatus& aStatus, 
       
   100                            const TScardReaderName& aReaderName );
       
   101 
       
   102         /**
       
   103         * Cancel notification.
       
   104         * @param aStatus Request status
       
   105         * @param aFriendlyName Name of the reader
       
   106         */
       
   107         /*void CancelNotifyChange( TRequestStatus& aStatus, 
       
   108                                  const TScardReaderName& aFriendlyName );*/
       
   109         TInt CancelNotifyChange( const TScardReaderName& aFriendlyName );
       
   110         
       
   111     private:    // Data
       
   112         // Pointer to CScard class. Not owned.
       
   113         RScard*          iScard;
       
   114         // Reader name
       
   115         TScardReaderName iReaderName;
       
   116         //Transfer to server side
       
   117         TPckgBuf<TRequestStatus*> iPckg;
       
   118     };
       
   119 
       
   120 #endif      // CSCARDLISTENER_H   
       
   121             
       
   122 // End of File