From 5fc7a22212933793e9d51cc16ded6a657a1eab71 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 21 Dec 2009 14:03:25 -0700 Subject: [PATCH] Driver for the Boox reader --- src/calibre/customize/builtins.py | 2 + src/calibre/devices/boox/__init__.py | 0 src/calibre/devices/boox/driver.py | 87 ++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 src/calibre/devices/boox/__init__.py create mode 100644 src/calibre/devices/boox/driver.py diff --git a/src/calibre/customize/builtins.py b/src/calibre/customize/builtins.py index 9e53a433ad..5b95f8f489 100644 --- a/src/calibre/customize/builtins.py +++ b/src/calibre/customize/builtins.py @@ -417,6 +417,7 @@ from calibre.devices.nokia.driver import N770, N810 from calibre.devices.eslick.driver import ESLICK from calibre.devices.nuut2.driver import NUUT2 from calibre.devices.iriver.driver import IRIVER_STORY +from calibre.devices.boox.driver import BOOX from calibre.ebooks.metadata.fetch import GoogleBooks, ISBNDB, Amazon plugins = [HTML2ZIP, PML2PMLZ, GoogleBooks, ISBNDB, Amazon] @@ -481,6 +482,7 @@ plugins += [ ITALICA, SHINEBOOK, ECLICTO, + BOOX, EB600, ] plugins += [x for x in list(locals().values()) if isinstance(x, type) and \ diff --git a/src/calibre/devices/boox/__init__.py b/src/calibre/devices/boox/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/calibre/devices/boox/driver.py b/src/calibre/devices/boox/driver.py new file mode 100644 index 0000000000..85495c459c --- /dev/null +++ b/src/calibre/devices/boox/driver.py @@ -0,0 +1,87 @@ +__license__ = 'GPL v3' +__copyright__ = '2009, Jesus Manuel Marinho Valcarce ' +__docformat__ = 'restructuredtext en' + +''' +Device driver for BOOX +''' + +import re + +from calibre.devices.usbms.driver import USBMS + +class BOOX(USBMS): + + name = 'BOOX driver' + gui_name = 'BOOX' + description = _('Communicate with the BOOX eBook reader.') + author = 'Jesus Manuel Marinho Valcarce' + supported_platforms = ['windows', 'osx', 'linux'] + + # Ordered list of supported formats + FORMATS = ['ebub', 'pdf', 'html', 'txt', 'rtf', 'mobi', 'prc', 'chm'] + + VENDOR_ID = [0x0525] + PRODUCT_ID = [0xa4a5] + BCD = [0x322] + + VENDOR_NAME = 'Linux 2.6.26-466-ga04670e with fsl-usb2-udc' + WINDOWS_MAIN_MEM = 'FILE-STOR_GADGET' + WINDOWS_CARD_A_MEM = 'FILE-STOR_GADGET' + + OSX_MAIN_MEM = 'Linux File-Stor Gadget Media' + OSX_CARD_A_MEM = 'Linux File-Stor Gadget Media' + + MAIN_MEMORY_VOLUME_LABEL = 'BOOX Internal Memory' + STORAGE_CARD_VOLUME_LABEL = 'BOOX Storage Card' + + EBOOK_DIR_MAIN = 'MyBooks' + EBOOK_DIR_CARD_A = 'MyBooks' + SUPPORTS_SUB_DIRS = True + + def windows_sort_drives(self, drives): + main = drives.get('main', None) + card = drives.get('carda', None) + if card and main and card > main: + drives['main'] = card + drives['carda'] = main + + if card and not main: + drives['main'] = card + drives['carda'] = None + + return drives + + def osx_sort_names(self, names): + main = names.get('main', None) + card = names.get('carda', None) + + try: + main_num = int(re.findall('\d+', main)[0]) if main else None + except: + main_num = None + try: + card_num = int(re.findall('\d+', card)[0]) if card else None + except: + card_num = None + + if card_num is not None and main_num is not None and card_num > main_num: + names['main'] = card + names['carda'] = main + + if card and not main: + names['main'] = card + names['carda'] = None + + return names + + def linux_swap_drives(self, drives): + if len(drives) < 2: return drives + drives = list(drives) + t = drives[0] + drives[0] = drives[1] + drives[1] = t + return tuple(drives) + + +