mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-31 14:33:54 -04:00
Add setting the fixed port to the smartdevice start dialog
This commit is contained in:
parent
b16d35f1f6
commit
3cae8e614d
@ -60,34 +60,35 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
|||||||
version = (0, 0, 1)
|
version = (0, 0, 1)
|
||||||
|
|
||||||
# Invalid USB vendor information so the scanner will never match
|
# Invalid USB vendor information so the scanner will never match
|
||||||
VENDOR_ID = [0xffff]
|
VENDOR_ID = [0xffff]
|
||||||
PRODUCT_ID = [0xffff]
|
PRODUCT_ID = [0xffff]
|
||||||
BCD = [0xffff]
|
BCD = [0xffff]
|
||||||
|
|
||||||
FORMATS = list(BOOK_EXTENSIONS)
|
FORMATS = list(BOOK_EXTENSIONS)
|
||||||
ALL_FORMATS = list(BOOK_EXTENSIONS)
|
ALL_FORMATS = list(BOOK_EXTENSIONS)
|
||||||
HIDE_FORMATS_CONFIG_BOX = True
|
HIDE_FORMATS_CONFIG_BOX = True
|
||||||
USER_CAN_ADD_NEW_FORMATS = False
|
USER_CAN_ADD_NEW_FORMATS = False
|
||||||
DEVICE_PLUGBOARD_NAME = 'SMART_DEVICE_APP'
|
DEVICE_PLUGBOARD_NAME = 'SMART_DEVICE_APP'
|
||||||
CAN_SET_METADATA = []
|
CAN_SET_METADATA = []
|
||||||
CAN_DO_DEVICE_DB_PLUGBOARD = False
|
CAN_DO_DEVICE_DB_PLUGBOARD = False
|
||||||
SUPPORTS_SUB_DIRS = False
|
SUPPORTS_SUB_DIRS = False
|
||||||
MUST_READ_METADATA = True
|
MUST_READ_METADATA = True
|
||||||
NEWS_IN_FOLDER = False
|
NEWS_IN_FOLDER = False
|
||||||
SUPPORTS_USE_AUTHOR_SORT = False
|
SUPPORTS_USE_AUTHOR_SORT = False
|
||||||
WANTS_UPDATED_THUMBNAILS = True
|
WANTS_UPDATED_THUMBNAILS = True
|
||||||
MAX_PATH_LEN = 100
|
MAX_PATH_LEN = 100
|
||||||
THUMBNAIL_HEIGHT = 160
|
THUMBNAIL_HEIGHT = 160
|
||||||
PREFIX = ''
|
PREFIX = ''
|
||||||
|
|
||||||
# Some network protocol constants
|
# Some network protocol constants
|
||||||
BASE_PACKET_LEN = 4096
|
BASE_PACKET_LEN = 4096
|
||||||
PROTOCOL_VERSION = 1
|
PROTOCOL_VERSION = 1
|
||||||
MAX_CLIENT_COMM_TIMEOUT = 60.0 # Wait at most N seconds for an answer
|
MAX_CLIENT_COMM_TIMEOUT = 60.0 # Wait at most N seconds for an answer
|
||||||
MAX_UNSUCCESSFUL_CONNECTS = 5
|
MAX_UNSUCCESSFUL_CONNECTS = 5
|
||||||
|
|
||||||
|
SEND_NOOP_EVERY_NTH_PROBE = 5
|
||||||
|
DISCONNECT_AFTER_N_SECONDS = 30*60 # 30 minutes
|
||||||
|
|
||||||
SEND_NOOP_EVERY_NTH_PROBE = 5
|
|
||||||
DISCONNECT_AFTER_N_SECONDS = 30 * 60 # 30 minutes
|
|
||||||
|
|
||||||
opcodes = {
|
opcodes = {
|
||||||
'NOOP' : 12,
|
'NOOP' : 12,
|
||||||
@ -109,9 +110,9 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
|||||||
'SET_CALIBRE_DEVICE_NAME': 2,
|
'SET_CALIBRE_DEVICE_NAME': 2,
|
||||||
'TOTAL_SPACE' : 4,
|
'TOTAL_SPACE' : 4,
|
||||||
}
|
}
|
||||||
reverse_opcodes = dict([(v, k) for k, v in opcodes.iteritems()])
|
reverse_opcodes = dict([(v, k) for k,v in opcodes.iteritems()])
|
||||||
|
|
||||||
ALL_BY_TITLE = _('All by title')
|
ALL_BY_TITLE = _('All by title')
|
||||||
ALL_BY_AUTHOR = _('All by author')
|
ALL_BY_AUTHOR = _('All by author')
|
||||||
|
|
||||||
EXTRA_CUSTOMIZATION_MESSAGE = [
|
EXTRA_CUSTOMIZATION_MESSAGE = [
|
||||||
@ -130,18 +131,18 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
|||||||
_('Check this box if requested when reporting problems') + '</p>',
|
_('Check this box if requested when reporting problems') + '</p>',
|
||||||
'',
|
'',
|
||||||
_('Comma separated list of metadata fields '
|
_('Comma separated list of metadata fields '
|
||||||
'to turn into collections on the device. Possibilities include: ') + \
|
'to turn into collections on the device. Possibilities include: ')+\
|
||||||
'series, tags, authors' + \
|
'series, tags, authors' +\
|
||||||
_('. Two special collections are available: %(abt)s:%(abtv)s and %(aba)s:%(abav)s. Add '
|
_('. Two special collections are available: %(abt)s:%(abtv)s and %(aba)s:%(abav)s. Add '
|
||||||
'these values to the list to enable them. The collections will be '
|
'these values to the list to enable them. The collections will be '
|
||||||
'given the name provided after the ":" character.') % dict(
|
'given the name provided after the ":" character.')%dict(
|
||||||
abt='abt', abtv=ALL_BY_TITLE, aba='aba', abav=ALL_BY_AUTHOR),
|
abt='abt', abtv=ALL_BY_TITLE, aba='aba', abav=ALL_BY_AUTHOR),
|
||||||
'',
|
'',
|
||||||
_('Enable the no-activity timeout') + ':::<p>' +
|
_('Enable the no-activity timeout') + ':::<p>' +
|
||||||
_('If this box is checked, calibre will automatically disconnect if '
|
_('If this box is checked, calibre will automatically disconnect if '
|
||||||
'a connected device does nothing for %d minutes. Unchecking this '
|
'a connected device does nothing for %d minutes. Unchecking this '
|
||||||
' box disables this timeout, so calibre will never automatically '
|
' box disables this timeout, so calibre will never automatically '
|
||||||
'disconnect.') % (DISCONNECT_AFTER_N_SECONDS / 60,) + '</p>',
|
'disconnect.')%(DISCONNECT_AFTER_N_SECONDS/60,) + '</p>',
|
||||||
]
|
]
|
||||||
EXTRA_CUSTOMIZATION_DEFAULT = [
|
EXTRA_CUSTOMIZATION_DEFAULT = [
|
||||||
False,
|
False,
|
||||||
@ -155,13 +156,14 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
|||||||
'',
|
'',
|
||||||
True,
|
True,
|
||||||
]
|
]
|
||||||
OPT_AUTOSTART = 0
|
OPT_AUTOSTART = 0
|
||||||
OPT_PASSWORD = 2
|
OPT_PASSWORD = 2
|
||||||
OPT_USE_PORT = 4
|
OPT_USE_PORT = 4
|
||||||
OPT_PORT_NUMBER = 5
|
OPT_PORT_NUMBER = 5
|
||||||
OPT_EXTRA_DEBUG = 6
|
OPT_EXTRA_DEBUG = 6
|
||||||
OPT_COLLECTIONS = 8
|
OPT_COLLECTIONS = 8
|
||||||
OPT_AUTODISCONNECT = 10
|
OPT_AUTODISCONNECT = 10
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, path):
|
def __init__(self, path):
|
||||||
self.sync_lock = threading.RLock()
|
self.sync_lock = threading.RLock()
|
||||||
@ -175,13 +177,13 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
|||||||
return
|
return
|
||||||
total_elapsed = time.time() - self.debug_start_time
|
total_elapsed = time.time() - self.debug_start_time
|
||||||
elapsed = time.time() - self.debug_time
|
elapsed = time.time() - self.debug_time
|
||||||
print('SMART_DEV (%7.2f:%7.3f) %s' % (total_elapsed, elapsed,
|
print('SMART_DEV (%7.2f:%7.3f) %s'%(total_elapsed, elapsed,
|
||||||
inspect.stack()[1][3]), end='')
|
inspect.stack()[1][3]), end='')
|
||||||
for a in args:
|
for a in args:
|
||||||
try:
|
try:
|
||||||
if isinstance(a, dict):
|
if isinstance(a, dict):
|
||||||
printable = {}
|
printable = {}
|
||||||
for k, v in a.iteritems():
|
for k,v in a.iteritems():
|
||||||
if isinstance(v, (str, unicode)) and len(v) > 50:
|
if isinstance(v, (str, unicode)) and len(v) > 50:
|
||||||
printable[k] = 'too long'
|
printable[k] = 'too long'
|
||||||
else:
|
else:
|
||||||
@ -251,7 +253,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
|||||||
if mdata.tags and _('News') in mdata.tags:
|
if mdata.tags and _('News') in mdata.tags:
|
||||||
try:
|
try:
|
||||||
p = mdata.pubdate
|
p = mdata.pubdate
|
||||||
date = (p.year, p.month, p.day)
|
date = (p.year, p.month, p.day)
|
||||||
except:
|
except:
|
||||||
today = time.localtime()
|
today = time.localtime()
|
||||||
date = (today[0], today[1], today[2])
|
date = (today[0], today[1], today[2])
|
||||||
@ -269,11 +271,11 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
|||||||
app_id = str(getattr(mdata, 'application_id', ''))
|
app_id = str(getattr(mdata, 'application_id', ''))
|
||||||
id_ = mdata.get('id', fname)
|
id_ = mdata.get('id', fname)
|
||||||
extra_components = get_components(template, mdata, id_,
|
extra_components = get_components(template, mdata, id_,
|
||||||
timefmt=opts.send_timefmt, length=maxlen - len(app_id) - 1)
|
timefmt=opts.send_timefmt, length=maxlen-len(app_id)-1)
|
||||||
if not extra_components:
|
if not extra_components:
|
||||||
extra_components.append(sanitize(fname))
|
extra_components.append(sanitize(fname))
|
||||||
else:
|
else:
|
||||||
extra_components[-1] = sanitize(extra_components[-1] + ext)
|
extra_components[-1] = sanitize(extra_components[-1]+ext)
|
||||||
|
|
||||||
if extra_components[-1] and extra_components[-1][0] in ('.', '_'):
|
if extra_components[-1] and extra_components[-1][0] in ('.', '_'):
|
||||||
extra_components[-1] = 'x' + extra_components[-1][1:]
|
extra_components[-1] = 'x' + extra_components[-1][1:]
|
||||||
@ -320,7 +322,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
|||||||
# codec to first convert it to a string dict
|
# codec to first convert it to a string dict
|
||||||
def _json_encode(self, op, arg):
|
def _json_encode(self, op, arg):
|
||||||
res = {}
|
res = {}
|
||||||
for k, v in arg.iteritems():
|
for k,v in arg.iteritems():
|
||||||
if isinstance(v, (Book, Metadata)):
|
if isinstance(v, (Book, Metadata)):
|
||||||
res[k] = self.json_codec.encode_book_metadata(v)
|
res[k] = self.json_codec.encode_book_metadata(v)
|
||||||
series = v.get('series', None)
|
series = v.get('series', None)
|
||||||
@ -493,6 +495,10 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
|||||||
return self.OPT_PASSWORD
|
return self.OPT_PASSWORD
|
||||||
elif opt_string == 'autostart':
|
elif opt_string == 'autostart':
|
||||||
return self.OPT_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
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -537,6 +543,19 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
|||||||
self.device_socket = None
|
self.device_socket = None
|
||||||
self.is_connected = False
|
self.is_connected = False
|
||||||
|
|
||||||
|
def _attach_to_port(self, port):
|
||||||
|
try:
|
||||||
|
self._debug('try port', port)
|
||||||
|
self.listen_socket.bind(('', port))
|
||||||
|
except socket.error:
|
||||||
|
self._debug('socket error on port', port)
|
||||||
|
port = 0
|
||||||
|
except:
|
||||||
|
self._debug('Unknown exception while allocating listen socket')
|
||||||
|
traceback.print_exc()
|
||||||
|
raise
|
||||||
|
return port
|
||||||
|
|
||||||
# The public interface methods.
|
# The public interface methods.
|
||||||
|
|
||||||
@synchronous('sync_lock')
|
@synchronous('sync_lock')
|
||||||
@ -783,7 +802,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
|||||||
coldict = {}
|
coldict = {}
|
||||||
if colattrs:
|
if colattrs:
|
||||||
collections = booklists[0].get_collections(colattrs)
|
collections = booklists[0].get_collections(colattrs)
|
||||||
for k, v in collections.iteritems():
|
for k,v in collections.iteritems():
|
||||||
lpaths = []
|
lpaths = []
|
||||||
for book in v:
|
for book in v:
|
||||||
lpaths.append(book.lpath)
|
lpaths.append(book.lpath)
|
||||||
@ -794,7 +813,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
|||||||
# given back by "books", and one that has been plugboarded.
|
# given back by "books", and one that has been plugboarded.
|
||||||
self._call_client('SEND_BOOKLISTS', { 'count': len(booklists[0]),
|
self._call_client('SEND_BOOKLISTS', { 'count': len(booklists[0]),
|
||||||
'collections': coldict})
|
'collections': coldict})
|
||||||
for i, book in enumerate(booklists[0]):
|
for i,book in enumerate(booklists[0]):
|
||||||
if not self._metadata_already_on_device(book):
|
if not self._metadata_already_on_device(book):
|
||||||
self._set_known_metadata(book)
|
self._set_known_metadata(book)
|
||||||
opcode, result = self._call_client('SEND_BOOK_METADATA',
|
opcode, result = self._call_client('SEND_BOOK_METADATA',
|
||||||
@ -937,57 +956,70 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
|||||||
self.noop_counter = 0
|
self.noop_counter = 0
|
||||||
self.connection_attempts = {}
|
self.connection_attempts = {}
|
||||||
self.client_can_stream_books = False
|
self.client_can_stream_books = False
|
||||||
|
|
||||||
|
message = None
|
||||||
try:
|
try:
|
||||||
self.listen_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
self.listen_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
except:
|
except:
|
||||||
self._debug('creation of listen socket failed')
|
message = 'creation of listen socket failed'
|
||||||
return
|
self._debug(message)
|
||||||
|
return message
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
while i < 100: # try up to 100 random port numbers
|
|
||||||
if self.settings().extra_customization[self.OPT_USE_PORT]:
|
if self.settings().extra_customization[self.OPT_USE_PORT]:
|
||||||
i = 100
|
|
||||||
try:
|
|
||||||
port = int(self.settings().extra_customization[self.OPT_PORT_NUMBER])
|
|
||||||
except:
|
|
||||||
port = 0
|
|
||||||
else:
|
|
||||||
i += 1
|
|
||||||
port = random.randint(8192, 32000)
|
|
||||||
try:
|
try:
|
||||||
self._debug('try port', port)
|
opt_port = int(self.settings().extra_customization[self.OPT_PORT_NUMBER])
|
||||||
self.listen_socket.bind(('', port))
|
|
||||||
break
|
|
||||||
except socket.error:
|
|
||||||
port = 0
|
|
||||||
except:
|
except:
|
||||||
self._debug('Unknown exception while allocating listen socket')
|
message = _('Invalid port in options: %s')% \
|
||||||
traceback.print_exc()
|
self.settings().extra_customization[self.OPT_PORT_NUMBER]
|
||||||
raise
|
self.debug(message)
|
||||||
if port == 0:
|
self.listen_socket.close()
|
||||||
self._debug('Failed to allocate a port');
|
self.listen_socket = None
|
||||||
self.listen_socket.close()
|
self.is_connected = False
|
||||||
self.listen_socket = None
|
return message
|
||||||
self.is_connected = False
|
|
||||||
return
|
port = self._attach_to_port(opt_port)
|
||||||
|
if port == 0:
|
||||||
|
message = 'Failed to connect to port %d'%opt_port
|
||||||
|
self._debug(message);
|
||||||
|
self.listen_socket.close()
|
||||||
|
self.listen_socket = None
|
||||||
|
self.is_connected = False
|
||||||
|
return message
|
||||||
|
else:
|
||||||
|
while i < 100: # try up to 100 random port numbers
|
||||||
|
i += 1
|
||||||
|
port = self._attach_to_port(random.randint(8192, 32000))
|
||||||
|
if port != 0:
|
||||||
|
break;
|
||||||
|
if port == 0:
|
||||||
|
message = _('Failed to allocate a random port')
|
||||||
|
self._debug(message);
|
||||||
|
self.listen_socket.close()
|
||||||
|
self.listen_socket = None
|
||||||
|
self.is_connected = False
|
||||||
|
return message
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.listen_socket.listen(0)
|
self.listen_socket.listen(0)
|
||||||
except:
|
except:
|
||||||
self._debug('listen on socket failed', port)
|
message = 'listen on port %d failed' % port
|
||||||
|
self._debug(message)
|
||||||
self.listen_socket.close()
|
self.listen_socket.close()
|
||||||
self.listen_socket = None
|
self.listen_socket = None
|
||||||
self.is_connected = False
|
self.is_connected = False
|
||||||
return
|
return message
|
||||||
|
|
||||||
try:
|
try:
|
||||||
do_zeroconf(publish_zeroconf, port)
|
do_zeroconf(publish_zeroconf, port)
|
||||||
except:
|
except:
|
||||||
self._debug('registration with bonjour failed')
|
message = 'registration with bonjour failed'
|
||||||
|
self._debug(message)
|
||||||
self.listen_socket.close()
|
self.listen_socket.close()
|
||||||
self.listen_socket = None
|
self.listen_socket = None
|
||||||
self.is_connected = False
|
self.is_connected = False
|
||||||
return
|
return message
|
||||||
|
|
||||||
self._debug('listening on port', port)
|
self._debug('listening on port', port)
|
||||||
self.port = port
|
self.port = port
|
||||||
@ -1008,7 +1040,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
|||||||
|
|
||||||
@synchronous('sync_lock')
|
@synchronous('sync_lock')
|
||||||
def start_plugin(self):
|
def start_plugin(self):
|
||||||
self.startup_on_demand()
|
return self.startup_on_demand()
|
||||||
|
|
||||||
@synchronous('sync_lock')
|
@synchronous('sync_lock')
|
||||||
def stop_plugin(self):
|
def stop_plugin(self):
|
||||||
|
@ -554,7 +554,7 @@ class DeviceManager(Thread): # {{{
|
|||||||
# will switch to the device thread before calling the plugin.
|
# will switch to the device thread before calling the plugin.
|
||||||
|
|
||||||
def start_plugin(self, name):
|
def start_plugin(self, name):
|
||||||
self._call_request(name, 'start_plugin')
|
return self._call_request(name, 'start_plugin')
|
||||||
|
|
||||||
def stop_plugin(self, name):
|
def stop_plugin(self, name):
|
||||||
self._call_request(name, 'stop_plugin')
|
self._call_request(name, 'stop_plugin')
|
||||||
|
@ -7,6 +7,7 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
|||||||
|
|
||||||
from PyQt4.Qt import (QDialog, QLineEdit, Qt)
|
from PyQt4.Qt import (QDialog, QLineEdit, Qt)
|
||||||
|
|
||||||
|
from calibre.gui2 import error_dialog
|
||||||
from calibre.gui2.dialogs.smartdevice_ui import Ui_Dialog
|
from calibre.gui2.dialogs.smartdevice_ui import Ui_Dialog
|
||||||
|
|
||||||
class SmartdeviceDialog(QDialog, Ui_Dialog):
|
class SmartdeviceDialog(QDialog, Ui_Dialog):
|
||||||
@ -27,7 +28,21 @@ class SmartdeviceDialog(QDialog, Ui_Dialog):
|
|||||||
'smart device interface when calibre starts. You should not do '
|
'smart device interface when calibre starts. You should not do '
|
||||||
'this if you are using a network that is not secure and you '
|
'this if you are using a network that is not secure and you '
|
||||||
'are not setting a password.') + '</p>')
|
'are not setting a password.') + '</p>')
|
||||||
|
|
||||||
|
self.use_fixed_port.setToolTip('<p>' +
|
||||||
|
_('Check this box if you want calibre to use a fixed network '
|
||||||
|
'port. Normally you will not need to do this. However, if '
|
||||||
|
'your device consistently fails to connect to calibre, '
|
||||||
|
'try checking this box.') + '</p>')
|
||||||
|
|
||||||
|
self.fixed_port.setToolTip('<p>' +
|
||||||
|
_('A port number must be a 4-digit integer less than 32,000. No '
|
||||||
|
'two network applications on the same computer can use '
|
||||||
|
'the same port number. If calibre says that it fails to connect '
|
||||||
|
'to the port, try a different number.') + '</p>')
|
||||||
|
|
||||||
self.show_password.stateChanged[int].connect(self.toggle_password)
|
self.show_password.stateChanged[int].connect(self.toggle_password)
|
||||||
|
self.use_fixed_port.stateChanged[int].connect(self.use_fixed_port_changed)
|
||||||
|
|
||||||
self.device_manager = parent.device_manager
|
self.device_manager = parent.device_manager
|
||||||
|
|
||||||
@ -37,8 +52,22 @@ class SmartdeviceDialog(QDialog, Ui_Dialog):
|
|||||||
pw = self.device_manager.get_option('smartdevice', 'password')
|
pw = self.device_manager.get_option('smartdevice', 'password')
|
||||||
if pw:
|
if pw:
|
||||||
self.password_box.setText(pw)
|
self.password_box.setText(pw)
|
||||||
|
|
||||||
|
use_fixed_port = self.device_manager.get_option('smartdevice', 'use_fixed_port')
|
||||||
|
port_number = self.device_manager.get_option('smartdevice', 'port_number')
|
||||||
|
self.fixed_port.setText(port_number)
|
||||||
|
self.use_fixed_port.setChecked(use_fixed_port);
|
||||||
|
if not use_fixed_port:
|
||||||
|
self.fixed_port.setEnabled(False);
|
||||||
|
|
||||||
|
if pw:
|
||||||
|
self.password_box.setText(pw)
|
||||||
|
|
||||||
self.resize(self.sizeHint())
|
self.resize(self.sizeHint())
|
||||||
|
|
||||||
|
def use_fixed_port_changed(self, state):
|
||||||
|
self.fixed_port.setEnabled(state == Qt.Checked)
|
||||||
|
|
||||||
def toggle_password(self, state):
|
def toggle_password(self, state):
|
||||||
self.password_box.setEchoMode(QLineEdit.Password if state ==
|
self.password_box.setEchoMode(QLineEdit.Password if state ==
|
||||||
Qt.Unchecked else QLineEdit.Normal)
|
Qt.Unchecked else QLineEdit.Normal)
|
||||||
@ -48,6 +77,16 @@ class SmartdeviceDialog(QDialog, Ui_Dialog):
|
|||||||
unicode(self.password_box.text()))
|
unicode(self.password_box.text()))
|
||||||
self.device_manager.set_option('smartdevice', 'autostart',
|
self.device_manager.set_option('smartdevice', 'autostart',
|
||||||
self.autostart_box.isChecked())
|
self.autostart_box.isChecked())
|
||||||
self.device_manager.start_plugin('smartdevice')
|
self.device_manager.set_option('smartdevice', 'use_fixed_port',
|
||||||
QDialog.accept(self)
|
self.use_fixed_port.isChecked())
|
||||||
|
self.device_manager.set_option('smartdevice', 'port_number',
|
||||||
|
unicode(self.fixed_port.text()))
|
||||||
|
|
||||||
|
message = self.device_manager.start_plugin('smartdevice')
|
||||||
|
|
||||||
|
if not self.device_manager.is_running('smartdevice'):
|
||||||
|
error_dialog(self, _('Problem starting smartdevice'),
|
||||||
|
_('The snart device driver did not start. It said "%s"')%message, show=True)
|
||||||
|
else:
|
||||||
|
QDialog.accept(self)
|
||||||
|
|
||||||
|
@ -71,6 +71,36 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="label_21">
|
||||||
|
<property name="text">
|
||||||
|
<string>Optional &fixed port:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>fixed_port</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QLineEdit" name="fixed_port">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>100</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>Optional port number</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="2">
|
||||||
|
<widget class="QCheckBox" name="use_fixed_port">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Use the fixed port</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="4" column="0" colspan="3">
|
<item row="4" column="0" colspan="3">
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user