mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-11-30 09:47:43 +03:00
Release CCID device between reads and don't read while hidden.
This commit is contained in:
parent
02ed3b9926
commit
45746ea036
@ -51,9 +51,12 @@ class ScardDevice(object):
|
||||
# print "RECV:", (''.join(map(chr, resp))).encode('hex')
|
||||
return ''.join(map(chr, resp)), sw1 << 8 | sw2
|
||||
|
||||
def __del__(self):
|
||||
def close(self):
|
||||
self._conn.disconnect()
|
||||
|
||||
def __del__(self):
|
||||
self.close()
|
||||
|
||||
|
||||
def open_scard(name='Yubikey'):
|
||||
name = name.lower()
|
||||
|
@ -114,7 +114,7 @@ class Controller(object):
|
||||
needs_touch[slot] = True
|
||||
except CardError:
|
||||
pass # No applet?
|
||||
del ccid_dev
|
||||
ccid_dev.close()
|
||||
|
||||
if self.otp_supported and ((slot1 and not legacy_creds[0])
|
||||
or (slot2 and not legacy_creds[1])):
|
||||
|
@ -113,6 +113,6 @@ class CardWatcher(object):
|
||||
def observe_reader(reader_name='Yubikey', callback=None):
|
||||
return CardWatcher(reader_name, callback)
|
||||
|
||||
if sys.platform == 'win32':
|
||||
if sys.platform == 'win32' or True:
|
||||
from .ccid_poll import observe_reader as _or
|
||||
observe_reader = _or
|
||||
|
@ -53,6 +53,9 @@ class LLScardDevice(object):
|
||||
return ''.join(map(chr, response[:-2])), status
|
||||
|
||||
def __del__(self):
|
||||
self.close()
|
||||
|
||||
def close(self):
|
||||
SCardDisconnect(self._card, SCARD_UNPOWER_CARD)
|
||||
SCardReleaseContext(self._context)
|
||||
|
||||
|
@ -301,11 +301,14 @@ class GuiController(QtCore.QObject, Controller):
|
||||
def refresh_codes(self, timestamp=None, lock=None):
|
||||
if not self._reader:
|
||||
return self._on_reader(self._watcher, self._watcher.reader)
|
||||
elif not self._app.window.isVisible():
|
||||
self._needs_read = True
|
||||
return
|
||||
lock = self.grab_lock(lock, True)
|
||||
if not lock:
|
||||
return
|
||||
device = self._watcher.open()
|
||||
self._needs_read = self._reader and device is None
|
||||
self._needs_read = bool(self._reader and device is None)
|
||||
timestamp = timestamp or self.timer.time
|
||||
try:
|
||||
creds = self.read_creds(device, self.slot1, self.slot2, timestamp)
|
||||
|
Loading…
Reference in New Issue
Block a user