Package smartcard :: Module AbstractCardRequest
[hide private]
[frames] | no frames]

Source Code for Module smartcard.AbstractCardRequest

 1  """AbstractCardRequest class. 
 2   
 3  __author__ = "http://www.gemalto.com" 
 4   
 5  Copyright 2001-2011 gemalto 
 6  Author: Jean-Daniel Aussel, mailto:jean-daniel.aussel@gemalto.com 
 7   
 8  This file is part of pyscard. 
 9   
10  pyscard is free software; you can redistribute it and/or modify 
11  it under the terms of the GNU Lesser General Public License as published by 
12  the Free Software Foundation; either version 2.1 of the License, or 
13  (at your option) any later version. 
14   
15  pyscard is distributed in the hope that it will be useful, 
16  but WITHOUT ANY WARRANTY; without even the implied warranty of 
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
18  GNU Lesser General Public License for more details. 
19   
20  You should have received a copy of the GNU Lesser General Public License 
21  along with pyscard; if not, write to the Free Software 
22  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 
23  """ 
24   
25  from smartcard.CardType import AnyCardType 
26  from smartcard.PassThruCardService import PassThruCardService 
27  import smartcard.System 
28   
29   
30 -class AbstractCardRequest:
31 """The base class for xxxCardRequest classes. 32 33 A CardRequest is used for waitForCard() invocations and specifies what 34 kind of smart card an application is waited for. 35 36 Known subclasses: smartcard.pcsc.PCSCCardRequest""" 37
38 - def __init__(self, newcardonly=False, readers=None, cardType=None, cardServiceClass=None, timeout=1):
39 """Construct new CardRequest. 40 41 newcardonly: if True, request a new card; default is 42 False, i.e. accepts cards already inserted 43 44 readers: the list of readers to consider for 45 requesting a card; default is to consider 46 all readers 47 48 cardType: the smartcard.CardType.CardType to wait for; 49 default is smartcard.CardType.AnyCardType, 50 i.e. the request will succeed with any card 51 52 cardServiceClass: the specific card service class to create 53 and bind to the card;default is to create 54 and bind a smartcard.PassThruCardService 55 56 timeout: the time in seconds we are ready to wait for 57 connecting to the requested card. default 58 is to wait one second; to wait forever, set 59 timeout to None 60 """ 61 self.newcardonly = newcardonly 62 self.readersAsked = readers 63 self.cardType = cardType 64 self.cardServiceClass = cardServiceClass 65 self.timeout = timeout 66 67 # if no CardType requeted, use AnyCardType 68 if None == self.cardType: 69 self.cardType = AnyCardType() 70 71 # if no card service requested, use pass-thru card service 72 if None == self.cardServiceClass: 73 self.cardServiceClass = PassThruCardService
74
75 - def getReaders(self):
76 """Returns the list or readers on which to wait for cards.""" 77 # if readers not given, use all readers 78 if None == self.readersAsked: 79 return smartcard.System.readers() 80 else: 81 return self.readersAsked
82
83 - def waitforcard(self):
84 """Wait for card insertion and returns a card service.""" 85 pass
86
87 - def waitforcardevent(self):
88 """Wait for card insertion or removal.""" 89 pass
90