1 """AbstractCardRequest class.
2
3 __author__ = "http://www.gemalto.com"
4
5 Copyright 2001-2012 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
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,
39 cardType=None, cardServiceClass=None, timeout=1):
40 """Construct new CardRequest.
41
42 @param newcardonly: if True, request a new card; default is
43 False, i.e. accepts cards already inserted
44
45 @param readers: the list of readers to consider for
46 requesting a card; default is to consider
47 all readers
48
49 @param cardType: the L{smartcard.CardType.CardType} to wait for;
50 default is L{smartcard.CardType.AnyCardType},
51 i.e. the request will succeed with any card
52
53 @param cardServiceClass: the specific card service class to create
54 and bind to the card;default is to create
55 and bind a L{smartcard.PassThruCardService}
56
57 @param timeout: the time in seconds we are ready to wait for
58 connecting to the requested card. default
59 is to wait one second; to wait forever, set
60 timeout to None
61 """
62 self.newcardonly = newcardonly
63 self.readersAsked = readers
64 self.cardType = cardType
65 self.cardServiceClass = cardServiceClass
66 self.timeout = timeout
67
68
69 if None == self.cardType:
70 self.cardType = AnyCardType()
71
72
73 if None == self.cardServiceClass:
74 self.cardServiceClass = PassThruCardService
75
77 """Returns the list or readers on which to wait for cards."""
78
79 if None == self.readersAsked:
80 return smartcard.System.readers()
81 else:
82 return self.readersAsked
83
85 """Wait for card insertion and returns a card service."""
86 pass
87
89 """Wait for card insertion or removal."""
90 pass
91