hw DeviceMgr: don't filter already paired devices in wizard
Related to prev commit: multiple (compatible) keystores can now match with the same HardwareClientBase, so we might as well also allow reusing existing Clients for the wizard.
This commit is contained in:
@@ -313,9 +313,9 @@ class BaseWizard(Logger):
|
|||||||
continue
|
continue
|
||||||
# see if plugin recognizes 'scanned_devices'
|
# see if plugin recognizes 'scanned_devices'
|
||||||
try:
|
try:
|
||||||
# FIXME: side-effect: unpaired_device_info sets client.handler
|
# FIXME: side-effect: this sets client.handler
|
||||||
device_infos = devmgr.unpaired_device_infos(None, plugin, devices=scanned_devices,
|
device_infos = devmgr.list_pairable_device_infos(
|
||||||
include_failing_clients=True)
|
handler=None, plugin=plugin, devices=scanned_devices, include_failing_clients=True)
|
||||||
except HardwarePluginLibraryUnavailable as e:
|
except HardwarePluginLibraryUnavailable as e:
|
||||||
failed_getting_device_infos(name, e)
|
failed_getting_device_infos(name, e)
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -585,17 +585,22 @@ class DeviceMgr(ThreadJob):
|
|||||||
'its seed (and passphrase, if any). Otherwise all bitcoins you '
|
'its seed (and passphrase, if any). Otherwise all bitcoins you '
|
||||||
'receive will be unspendable.').format(plugin.device))
|
'receive will be unspendable.').format(plugin.device))
|
||||||
|
|
||||||
def unpaired_device_infos(self, handler: Optional['HardwareHandlerBase'], plugin: 'HW_PluginBase',
|
def list_pairable_device_infos(
|
||||||
devices: Sequence['Device'] = None,
|
self,
|
||||||
include_failing_clients=False) -> List['DeviceInfo']:
|
*,
|
||||||
'''Returns a list of DeviceInfo objects: one for each connected,
|
handler: Optional['HardwareHandlerBase'],
|
||||||
unpaired device accepted by the plugin.'''
|
plugin: 'HW_PluginBase',
|
||||||
|
devices: Sequence['Device'] = None,
|
||||||
|
include_failing_clients: bool = False,
|
||||||
|
) -> List['DeviceInfo']:
|
||||||
|
"""Returns a list of DeviceInfo objects: one for each connected device accepted by the plugin.
|
||||||
|
Already paired devices are also included, as it is okay to reuse them.
|
||||||
|
"""
|
||||||
if not plugin.libraries_available:
|
if not plugin.libraries_available:
|
||||||
message = plugin.get_library_not_available_message()
|
message = plugin.get_library_not_available_message()
|
||||||
raise HardwarePluginLibraryUnavailable(message)
|
raise HardwarePluginLibraryUnavailable(message)
|
||||||
if devices is None:
|
if devices is None:
|
||||||
devices = self.scan_devices()
|
devices = self.scan_devices()
|
||||||
devices = [dev for dev in devices if not self.pairing_code_by_id(dev.id_)]
|
|
||||||
infos = []
|
infos = []
|
||||||
for device in devices:
|
for device in devices:
|
||||||
if not plugin.can_recognize_device(device):
|
if not plugin.can_recognize_device(device):
|
||||||
@@ -629,7 +634,7 @@ class DeviceMgr(ThreadJob):
|
|||||||
# ideally this should not be called from the GUI thread...
|
# ideally this should not be called from the GUI thread...
|
||||||
# assert handler.get_gui_thread() != threading.current_thread(), 'must not be called from GUI thread'
|
# assert handler.get_gui_thread() != threading.current_thread(), 'must not be called from GUI thread'
|
||||||
while True:
|
while True:
|
||||||
infos = self.unpaired_device_infos(handler, plugin, devices)
|
infos = self.list_pairable_device_infos(handler=handler, plugin=plugin, devices=devices)
|
||||||
if infos:
|
if infos:
|
||||||
break
|
break
|
||||||
if not allow_user_interaction:
|
if not allow_user_interaction:
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ def get_connected_hw_devices(plugins: 'Plugins'):
|
|||||||
_logger.error(f"{name}: error during plugin init: {repr(e)}")
|
_logger.error(f"{name}: error during plugin init: {repr(e)}")
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
u = devmgr.unpaired_device_infos(None, plugin)
|
u = devmgr.list_pairable_device_infos(handler=None, plugin=plugin)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
_logger.error(f'error getting device infos for {name}: {repr(e)}')
|
_logger.error(f'error getting device infos for {name}: {repr(e)}')
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user