mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Send books to the device using a pure binary protocol
This commit is contained in:
parent
2981ddf0a5
commit
810aa02b74
@ -89,6 +89,8 @@ class ConnectionListener (Thread):
|
|||||||
except Queue.Empty:
|
except Queue.Empty:
|
||||||
pass
|
pass
|
||||||
queue_not_serviced_count = 0
|
queue_not_serviced_count = 0
|
||||||
|
else:
|
||||||
|
queue_not_serviced_count = 0
|
||||||
|
|
||||||
if getattr(self.driver, 'broadcast_socket', None) is not None:
|
if getattr(self.driver, 'broadcast_socket', None) is not None:
|
||||||
while True:
|
while True:
|
||||||
@ -140,7 +142,7 @@ class ConnectionListener (Thread):
|
|||||||
try:
|
try:
|
||||||
self.driver.connection_queue.put_nowait(device_socket)
|
self.driver.connection_queue.put_nowait(device_socket)
|
||||||
except Queue.Full:
|
except Queue.Full:
|
||||||
device_socket.close();
|
device_socket.close()
|
||||||
device_socket = None
|
device_socket = None
|
||||||
self.driver._debug('driver is not answering')
|
self.driver._debug('driver is not answering')
|
||||||
|
|
||||||
@ -577,7 +579,8 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
|||||||
opcode, result = self._call_client('SEND_BOOK', {'lpath': lpath, 'length': length,
|
opcode, result = self._call_client('SEND_BOOK', {'lpath': lpath, 'length': length,
|
||||||
'metadata': book_metadata, 'thisBook': this_book,
|
'metadata': book_metadata, 'thisBook': this_book,
|
||||||
'totalBooks': total_books,
|
'totalBooks': total_books,
|
||||||
'willStreamBooks': self.client_can_stream_books},
|
'willStreamBooks': self.client_can_stream_books,
|
||||||
|
'willStreamBinary' : self.client_can_receive_book_binary},
|
||||||
print_debug_info=False,
|
print_debug_info=False,
|
||||||
wait_for_response=(not self.client_can_stream_books))
|
wait_for_response=(not self.client_can_stream_books))
|
||||||
|
|
||||||
@ -590,6 +593,9 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
|||||||
blen = len(b)
|
blen = len(b)
|
||||||
if not b:
|
if not b:
|
||||||
break
|
break
|
||||||
|
if self.client_can_stream_books and self.client_can_receive_book_binary:
|
||||||
|
self._send_byte_string(self.device_socket, b)
|
||||||
|
else:
|
||||||
b = b64encode(b)
|
b = b64encode(b)
|
||||||
opcode, result = self._call_client('BOOK_DATA',
|
opcode, result = self._call_client('BOOK_DATA',
|
||||||
{'lpath': lpath, 'position': pos, 'data': b},
|
{'lpath': lpath, 'position': pos, 'data': b},
|
||||||
@ -600,6 +606,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
|||||||
self._debug('protocol error', opcode)
|
self._debug('protocol error', opcode)
|
||||||
failed = True
|
failed = True
|
||||||
break
|
break
|
||||||
|
if not (self.client_can_stream_books and self.client_can_receive_book_binary):
|
||||||
self._call_client('BOOK_DONE', {'lpath': lpath})
|
self._call_client('BOOK_DONE', {'lpath': lpath})
|
||||||
self.time = None
|
self.time = None
|
||||||
if close_:
|
if close_:
|
||||||
@ -799,6 +806,8 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
|||||||
self._debug('Device can stream books', self.client_can_stream_books)
|
self._debug('Device can stream books', self.client_can_stream_books)
|
||||||
self.client_can_stream_metadata = result.get('canStreamMetadata', False)
|
self.client_can_stream_metadata = result.get('canStreamMetadata', False)
|
||||||
self._debug('Device can stream metadata', self.client_can_stream_metadata)
|
self._debug('Device can stream metadata', self.client_can_stream_metadata)
|
||||||
|
self.client_can_receive_book_binary = result.get('canReceiveBookBinary', False)
|
||||||
|
self._debug('Device can receive book binary', self.client_can_stream_metadata)
|
||||||
|
|
||||||
self.max_book_packet_len = result.get('maxBookContentPacketLen',
|
self.max_book_packet_len = result.get('maxBookContentPacketLen',
|
||||||
self.BASE_PACKET_LEN)
|
self.BASE_PACKET_LEN)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user