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,28 +323,30 @@ 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):
if not DEBUG: # manual synchronization so we don't lose the calling method name
return with self.sync_lock:
total_elapsed = time.time() - self.debug_start_time if not DEBUG:
elapsed = time.time() - self.debug_time return
print('SMART_DEV (%7.2f:%7.3f) %s'%(total_elapsed, elapsed, total_elapsed = time.time() - self.debug_start_time
inspect.stack()[1][3]), end='') elapsed = time.time() - self.debug_time
for a in args: print('SMART_DEV (%7.2f:%7.3f) %s'%(total_elapsed, elapsed,
try: inspect.stack()[1][3]), end='')
if isinstance(a, dict): for a in args:
printable = {} try:
for k,v in a.iteritems(): if isinstance(a, dict):
if isinstance(v, (str, unicode)) and len(v) > 50: printable = {}
printable[k] = 'too long' for k,v in a.iteritems():
else: if isinstance(v, (str, unicode)) and len(v) > 50:
printable[k] = v printable[k] = 'too long'
prints('', printable, end='') else:
else: printable[k] = v
prints('', a, end='') prints('', printable, end='')
except: else:
prints('', 'value too long', end='') prints('', a, end='')
print() except:
self.debug_time = time.time() prints('', 'value too long', end='')
print()
self.debug_time = time.time()
# local utilities # local utilities
@ -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,