diff --git a/src/calibre/devices/interface.py b/src/calibre/devices/interface.py index 85d25d82a4..04d61a25dc 100644 --- a/src/calibre/devices/interface.py +++ b/src/calibre/devices/interface.py @@ -41,6 +41,20 @@ class Device(object): '''Return the FDI description of this device for HAL on linux.''' return '' + @classmethod + def can_handle(cls, device_info): + ''' + Optional method to perform further checks on a device to see if this driver + is capable of handling it. If it is not it should return False. This method + is only called after the vendor, product ids and the bcd have matched, so + it can do some relatively time intensive checks. The default implementation + returns True. + + :param device_info: On windows a device ID string. On Unix a tuple of + ``(vendor_id, product_id, bcd)``. + ''' + return True + def open(self): ''' Perform any device specific initialization. Called after the device is diff --git a/src/calibre/devices/scanner.py b/src/calibre/devices/scanner.py index ec937fc84d..26ea67ea44 100644 --- a/src/calibre/devices/scanner.py +++ b/src/calibre/devices/scanner.py @@ -63,12 +63,14 @@ class DeviceScanner(object): for device_id in self.devices: if vid in device_id and pid in device_id: if self.test_bcd_windows(device_id, getattr(device, 'BCD', None)): - return True + if device.can_handle(device_id): + return True else: for vendor, product, bcdDevice in self.devices: if device.VENDOR_ID == vendor and device.PRODUCT_ID == product: if self.test_bcd(bcdDevice, getattr(device, 'BCD', None)): - return True + if device.can_handle((vendor, product, bcdDevice)): + return True return False