mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix a misbehaving wireless device connection can cause calibre to hang when opening the Connect/Share menu. Fixes #1676522 [Private bug](https://bugs.launchpad.net/calibre/+bug/1676522)
This commit is contained in:
parent
8aec77a672
commit
dc74e17b86
@ -347,6 +347,14 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
|||||||
OPT_OVERWRITE_BOOKS_UUID = 12
|
OPT_OVERWRITE_BOOKS_UUID = 12
|
||||||
OPT_COMPRESSION_QUALITY = 13
|
OPT_COMPRESSION_QUALITY = 13
|
||||||
OPT_USE_METADATA_CACHE = 14
|
OPT_USE_METADATA_CACHE = 14
|
||||||
|
OPTNAME_TO_NUMBER_MAP = {
|
||||||
|
'password': OPT_PASSWORD,
|
||||||
|
'autostart': OPT_AUTOSTART,
|
||||||
|
'use_fixed_port': OPT_USE_PORT,
|
||||||
|
'port_number': OPT_PORT_NUMBER,
|
||||||
|
'force_ip_address': OPT_FORCE_IP_ADDRESS,
|
||||||
|
'thumbnail_compression_quality': OPT_COMPRESSION_QUALITY,
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(self, path):
|
def __init__(self, path):
|
||||||
self.sync_lock = threading.RLock()
|
self.sync_lock = threading.RLock()
|
||||||
@ -695,22 +703,6 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
|||||||
infile.close()
|
infile.close()
|
||||||
return (-1, None) if failed else (length, lpath)
|
return (-1, None) if failed else (length, lpath)
|
||||||
|
|
||||||
def _get_smartdevice_option_number(self, opt_string):
|
|
||||||
if opt_string == 'password':
|
|
||||||
return self.OPT_PASSWORD
|
|
||||||
elif opt_string == 'autostart':
|
|
||||||
return self.OPT_AUTOSTART
|
|
||||||
elif opt_string == 'use_fixed_port':
|
|
||||||
return self.OPT_USE_PORT
|
|
||||||
elif opt_string == 'port_number':
|
|
||||||
return self.OPT_PORT_NUMBER
|
|
||||||
elif opt_string == 'force_ip_address':
|
|
||||||
return self.OPT_FORCE_IP_ADDRESS
|
|
||||||
elif opt_string == 'thumbnail_compression_quality':
|
|
||||||
return self.OPT_COMPRESSION_QUALITY
|
|
||||||
else:
|
|
||||||
return None
|
|
||||||
|
|
||||||
def _metadata_in_cache(self, uuid, ext_or_lpath, lastmod):
|
def _metadata_in_cache(self, uuid, ext_or_lpath, lastmod):
|
||||||
from calibre.utils.date import now, parse_date
|
from calibre.utils.date import now, parse_date
|
||||||
try:
|
try:
|
||||||
@ -1960,7 +1952,6 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
|||||||
|
|
||||||
# Methods for dynamic control
|
# Methods for dynamic control
|
||||||
|
|
||||||
@synchronous('sync_lock')
|
|
||||||
def is_dynamically_controllable(self):
|
def is_dynamically_controllable(self):
|
||||||
return 'smartdevice'
|
return 'smartdevice'
|
||||||
|
|
||||||
@ -1972,24 +1963,19 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
|||||||
def stop_plugin(self):
|
def stop_plugin(self):
|
||||||
self.shutdown()
|
self.shutdown()
|
||||||
|
|
||||||
@synchronous('sync_lock')
|
|
||||||
def get_option(self, opt_string, default=None):
|
def get_option(self, opt_string, default=None):
|
||||||
opt = self._get_smartdevice_option_number(opt_string)
|
opt = self.OPTNAME_TO_NUMBER_MAP.get(opt_string)
|
||||||
if opt is not None:
|
if opt is not None:
|
||||||
return self.settings().extra_customization[opt]
|
return self.settings().extra_customization[opt]
|
||||||
return default
|
return default
|
||||||
|
|
||||||
@synchronous('sync_lock')
|
|
||||||
def set_option(self, opt_string, value):
|
def set_option(self, opt_string, value):
|
||||||
opt = self._get_smartdevice_option_number(opt_string)
|
opt = self.OPTNAME_TO_NUMBER_MAP.get(opt_string)
|
||||||
if opt is not None:
|
if opt is not None:
|
||||||
config = self._configProxy()
|
config = self._configProxy()
|
||||||
ec = config['extra_customization']
|
ec = config['extra_customization']
|
||||||
ec[opt] = value
|
ec[opt] = value
|
||||||
config['extra_customization'] = ec
|
config['extra_customization'] = ec
|
||||||
|
|
||||||
@synchronous('sync_lock')
|
|
||||||
def is_running(self):
|
def is_running(self):
|
||||||
return getattr(self, 'listen_socket', None) is not None
|
return getattr(self, 'listen_socket', None) is not None
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user