From 12c65154789fb2be26c445450fc0b9f619e70c24 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Thu, 23 Aug 2012 11:59:42 +0200 Subject: [PATCH 1/3] Remove unused code --- .../devices/smart_device_app/driver.py | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/src/calibre/devices/smart_device_app/driver.py b/src/calibre/devices/smart_device_app/driver.py index aaef36d8d9..4b749b21ca 100644 --- a/src/calibre/devices/smart_device_app/driver.py +++ b/src/calibre/devices/smart_device_app/driver.py @@ -503,25 +503,6 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin): else: return None -# def _compare_metadata(self, mi1, mi2): -# for key in SERIALIZABLE_FIELDS: -# if key in ['cover', 'mime']: -# continue -# if key == 'user_metadata': -# meta1 = mi1.get_all_user_metadata(make_copy=False) -# meta2 = mi1.get_all_user_metadata(make_copy=False) -# if meta1 != meta2: -# self._debug('custom metadata different') -# return False -# for ckey in meta1: -# if mi1.get(ckey) != mi2.get(ckey): -# self._debug(ckey, mi1.get(ckey), mi2.get(ckey)) -# return False -# elif mi1.get(key, None) != mi2.get(key, None): -# self._debug(key, mi1.get(key), mi2.get(key)) -# return False -# return True - def _metadata_already_on_device(self, book): v = self.known_metadata.get(book.lpath, None) if v is not None: From aae85f93284051ad4426f0765567fa0b32fd4c69 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Thu, 23 Aug 2012 20:38:56 +0200 Subject: [PATCH 2/3] Improved error messages and a critical bug fix. --- .../devices/smart_device_app/driver.py | 4 +-- src/calibre/gui2/dialogs/smartdevice.py | 26 +++++++++++++++---- 2 files changed, 23 insertions(+), 7 deletions(-) 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', From 043be33cc8f2a14d032d6a51e6d7d50fa8ba8ae5 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Thu, 23 Aug 2012 21:43:43 +0200 Subject: [PATCH 3/3] fix typo --- src/calibre/gui2/dialogs/smartdevice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/gui2/dialogs/smartdevice.py b/src/calibre/gui2/dialogs/smartdevice.py index d8536a15cb..5de933a21c 100644 --- a/src/calibre/gui2/dialogs/smartdevice.py +++ b/src/calibre/gui2/dialogs/smartdevice.py @@ -37,7 +37,7 @@ class SmartdeviceDialog(QDialog, Ui_Dialog): self.fixed_port.setToolTip('' + _('Try 9090. If calibre says that it fails to connect ' - 'to the port, try another number. Yu can use any number between ' + 'to the port, try another number. You can use any number between ' '8,000 and 32,000.') + '
') self.show_password.stateChanged[int].connect(self.toggle_password)