From: <lu...@us...> - 2010-01-21 14:35:15
|
Revision: 368 http://pyscard.svn.sourceforge.net/pyscard/?rev=368&view=rev Author: ludov Date: 2010-01-21 14:34:40 +0000 (Thu, 21 Jan 2010) Log Message: ----------- connect() now have a new optionnal parameter disposition= passed to SCardDisconnect(). The default value is SCARD_UNPOWER_CARD as before. It is now possible to disconnect from a card without resetting the card using disposition=SCARD_LEAVE_CARD Modified Paths: -------------- trunk/pyscard/src/smartcard/CardConnectionDecorator.py trunk/pyscard/src/smartcard/pcsc/PCSCCardConnection.py Modified: trunk/pyscard/src/smartcard/CardConnectionDecorator.py =================================================================== --- trunk/pyscard/src/smartcard/CardConnectionDecorator.py 2010-01-02 20:56:18 UTC (rev 367) +++ trunk/pyscard/src/smartcard/CardConnectionDecorator.py 2010-01-21 14:34:40 UTC (rev 368) @@ -48,9 +48,9 @@ """call inner component deleteObserver""" self.component.deleteObserver( observer ) - def connect( self, protocol=None, mode=None ): + def connect( self, protocol=None, mode=None, disposition=None ): """call inner component connect""" - self.component.connect( protocol, mode ) + self.component.connect( protocol, mode, disposition ) def disconnect( self ): """call inner component disconnect""" Modified: trunk/pyscard/src/smartcard/pcsc/PCSCCardConnection.py =================================================================== --- trunk/pyscard/src/smartcard/pcsc/PCSCCardConnection.py 2010-01-02 20:56:18 UTC (rev 367) +++ trunk/pyscard/src/smartcard/pcsc/PCSCCardConnection.py 2010-01-21 14:34:40 UTC (rev 368) @@ -82,7 +82,7 @@ raise CardConnectionException( 'Failed to release context: ' + SCardGetErrorMessage(hresult) ) CardConnection.__del__( self ) - def connect( self, protocol=None, mode=None ): + def connect( self, protocol=None, mode=None, disposition=None ): """Connect to the card. If protocol is not specified, connect with the default connection protocol. @@ -95,6 +95,12 @@ if mode==None: mode = SCARD_SHARE_SHARED + + # store the way to dispose the card + if disposition==None: + disposition = SCARD_UNPOWER_CARD + self.disposition = disposition + hresult, self.hcard, dwActiveProtocol = SCardConnect( self.hcontext, str(self.reader), mode, pcscprotocol ) if hresult!=0: @@ -121,7 +127,7 @@ except TypeError: pass if None!=self.hcard: - hresult = SCardDisconnect( self.hcard, SCARD_UNPOWER_CARD ) + hresult = SCardDisconnect( self.hcard, self.disposition ) if hresult!=0: raise CardConnectionException( 'Failed to disconnect: ' + SCardGetErrorMessage(hresult) ) self.hcard = None This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |