Put the device kind when the wireless driver connects

This commit is contained in:
Charles Haley 2012-09-20 09:04:53 +02:00
parent 7571cbf7ac
commit 17e56c57b4

View File

@ -163,7 +163,9 @@ class SDBook(Book):
class SMART_DEVICE_APP(DeviceConfig, DevicePlugin): class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
name = 'SmartDevice App Interface' name = 'SmartDevice App Interface'
gui_name = _('SmartDevice') gui_name = _('Wireless Device')
gui_name_template = '%s: %s'
icon = I('devices/galaxy_s3.png') icon = I('devices/galaxy_s3.png')
description = _('Communicate with Smart Device apps') description = _('Communicate with Smart Device apps')
supported_platforms = ['windows', 'osx', 'linux'] supported_platforms = ['windows', 'osx', 'linux']
@ -321,6 +323,8 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
self.client_can_stream_metadata = False self.client_can_stream_metadata = False
def _debug(self, *args): def _debug(self, *args):
# manual synchronization so we don't lose the calling method name
with self.sync_lock:
if not DEBUG: if not DEBUG:
return return
total_elapsed = time.time() - self.debug_start_time total_elapsed = time.time() - self.debug_start_time
@ -825,6 +829,9 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
self.client_can_receive_book_binary = result.get('canReceiveBookBinary', False) self.client_can_receive_book_binary = result.get('canReceiveBookBinary', False)
self._debug('Device can receive book binary', self.client_can_stream_metadata) self._debug('Device can receive book binary', self.client_can_stream_metadata)
self.client_device_kind = result.get('deviceKind', '')
self._debug('Client device kind', self.client_device_kind)
self.max_book_packet_len = result.get('maxBookContentPacketLen', self.max_book_packet_len = result.get('maxBookContentPacketLen',
self.BASE_PACKET_LEN) self.BASE_PACKET_LEN)
self._debug('max_book_packet_len', self.max_book_packet_len) self._debug('max_book_packet_len', self.max_book_packet_len)
@ -886,6 +893,13 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
raise raise
return False return False
@synchronous('sync_lock')
def get_gui_name(self):
if self.client_device_kind:
return self.gui_name_template%(self.gui_name, self.client_device_kind)
return self.gui_name
@synchronous('sync_lock') @synchronous('sync_lock')
def get_device_information(self, end_session=True): def get_device_information(self, end_session=True):
self._debug() self._debug()
@ -1039,6 +1053,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
@synchronous('sync_lock') @synchronous('sync_lock')
def post_yank_cleanup(self): def post_yank_cleanup(self):
self._debug() self._debug()
self.gui_name = self.gui_name_base
@synchronous('sync_lock') @synchronous('sync_lock')
def upload_books(self, files, names, on_card=None, end_session=True, def upload_books(self, files, names, on_card=None, end_session=True,