diff --git a/src/calibre/devices/smart_device_app/driver.py b/src/calibre/devices/smart_device_app/driver.py index 4b749b21ca..33767d3e24 100644 --- a/src/calibre/devices/smart_device_app/driver.py +++ b/src/calibre/devices/smart_device_app/driver.py @@ -976,7 +976,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin): except: message = _('Invalid port in options: %s')% \ self.settings().extra_customization[self.OPT_PORT_NUMBER] - self.debug(message) + self._debug(message) self.listen_socket.close() self.listen_socket = None self.is_connected = False @@ -984,7 +984,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin): port = self._attach_to_port(opt_port) if port == 0: - message = 'Failed to connect to port %d'%opt_port + message = _('Failed to connect to port %d. Try a different value.')%opt_port self._debug(message) self.listen_socket.close() self.listen_socket = None diff --git a/src/calibre/gui2/dialogs/smartdevice.py b/src/calibre/gui2/dialogs/smartdevice.py index 1a8829323b..d8536a15cb 100644 --- a/src/calibre/gui2/dialogs/smartdevice.py +++ b/src/calibre/gui2/dialogs/smartdevice.py @@ -33,13 +33,12 @@ class SmartdeviceDialog(QDialog, Ui_Dialog): _('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.') + '
') + 'try checking this box and entering a number.') + '') self.fixed_port.setToolTip('' + - _('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.') + '
') + _('Try 9090. If calibre says that it fails to connect ' + 'to the port, try another number. Yu can use any number between ' + '8,000 and 32,000.') + '') self.show_password.stateChanged[int].connect(self.toggle_password) self.use_fixed_port.stateChanged[int].connect(self.use_fixed_port_changed) @@ -75,6 +74,23 @@ class SmartdeviceDialog(QDialog, Ui_Dialog): Qt.Unchecked else QLineEdit.Normal) def accept(self): + port = unicode(self.fixed_port.text()) + if not port: + error_dialog(self, _('Invalid port number'), + _('You must provide a port number.'), show=True) + return + try: + port = int(port) + except: + error_dialog(self, _('Invalid port number'), + _('The port must be a number between 8000 and 32000.'), show=True) + return + + if port < 8000 or port > 32000: + error_dialog(self, _('Invalid port number'), + _('The port must be a number between 8000 and 32000.'), show=True) + return + self.device_manager.set_option('smartdevice', 'password', unicode(self.password_box.text())) self.device_manager.set_option('smartdevice', 'autostart',