~ubuntu-branches/ubuntu/karmic/calibre/karmic

« back to all changes in this revision

Viewing changes to src/calibre/devices/bebook/driver.py

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-07-30 12:49:41 UTC
  • mfrom: (1.3.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090730124941-qjdsmri25zt8zocn
Tags: 0.6.3+dfsg-0ubuntu1
* New upstream release. Please see http://calibre.kovidgoyal.net/new_in_6/
  for the list of new features and changes.
* remove_postinstall.patch: Update for new version.
* build_debug.patch: Does not apply any more, disable for now. Might not be
  necessary any more.
* debian/copyright: Fix reference to versionless GPL.
* debian/rules: Drop obsolete dh_desktop call.
* debian/rules: Add workaround for weird Python 2.6 setuptools behaviour of
  putting compiled .so files into src/calibre/plugins/calibre/plugins
  instead of src/calibre/plugins.
* debian/rules: Drop hal fdi moving, new upstream version does not use hal
  any more. Drop hal dependency, too.
* debian/rules: Install udev rules into /lib/udev/rules.d.
* Add debian/calibre.preinst: Remove unmodified
  /etc/udev/rules.d/95-calibre.rules on upgrade.
* debian/control: Bump Python dependencies to 2.6, since upstream needs
  it now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
__license__   = 'GPL v3'
2
2
__copyright__ = '2009, Tijmen Ruizendaal <tijmen at mybebook.com>'
 
3
 
3
4
'''
4
5
Device driver for BeBook
5
6
'''
6
7
 
 
8
import re
 
9
 
7
10
from calibre.devices.usbms.driver import USBMS
8
11
 
9
12
class BEBOOK(USBMS):
 
13
    name           = 'BeBook driver'
 
14
    description    = _('Communicate with the BeBook eBook reader.')
 
15
    author         = 'Tijmen Ruizendaal'
 
16
    supported_platforms = ['windows', 'osx', 'linux']
 
17
 
 
18
 
10
19
    # Ordered list of supported formats
11
20
    FORMATS     = ['mobi', 'epub', 'pdf', 'txt']
12
21
 
13
22
    VENDOR_ID   = [0x0525]
14
23
    PRODUCT_ID  = [0x8803, 0x6803]
15
 
    BCD         = [0x312]
 
24
    BCD         = [0x312]
16
25
 
17
 
    VENDOR_NAME = 'LINUX'
 
26
    VENDOR_NAME      = 'LINUX'
18
27
    WINDOWS_MAIN_MEM = 'FILE-STOR_GADGET'
19
 
    WINDOWS_CARD_MEM = 'FILE-STOR_GADGET'
 
28
    WINDOWS_CARD_A_MEM = 'FILE-STOR_GADGET'
20
29
 
21
 
    OSX_MAIN_MEM = 'BeBook Internal Memory'
22
 
    OSX_CARD_MEM = 'BeBook Storage Card'
 
30
    OSX_MAIN_MEM = 'Linux File-Stor Gadget Media'
 
31
    OSX_CARD_A_MEM = 'Linux File-Stor Gadget Media'
23
32
 
24
33
    MAIN_MEMORY_VOLUME_LABEL  = 'BeBook Internal Memory'
25
34
    STORAGE_CARD_VOLUME_LABEL = 'BeBook Storage Card'
26
35
 
27
36
    SUPPORTS_SUB_DIRS = True
28
37
 
29
 
    FDI_LUNS = {'lun0':1, 'lun1':0, 'lun2':2}
30
 
 
31
38
    def windows_sort_drives(self, drives):
32
39
        main = drives.get('main', None)
33
 
        card = drives.get('card', None)
34
 
        if card and main and card < main:
35
 
            drives['main'] = card
36
 
            drives['card'] = main
 
40
        card = drives.get('carda', None)
 
41
        if card and main and card > main:
 
42
            drives['main'] = card
 
43
            drives['carda'] = main
 
44
 
 
45
        if card and not main:
 
46
            drives['main'] = card
 
47
            drives['carda'] = None
37
48
 
38
49
        return drives
39
50
 
40
 
 
41
 
 
42
 
class BEBOOKMINI(BEBOOK):
 
51
    def osx_sort_names(self, names):
 
52
        main = names.get('main', None)
 
53
        card = names.get('carda', None)
 
54
 
 
55
        try:
 
56
            main_num = int(re.findall('\d+', main)[0]) if main else None
 
57
        except:
 
58
            main_num = None
 
59
        try:
 
60
            card_num = int(re.findall('\d+', card)[0]) if card else None
 
61
        except:
 
62
            card_num = None
 
63
 
 
64
        if card_num is not None and main_num is not None and card_num > main_num:
 
65
            names['main'] = card
 
66
            names['carda'] = main
 
67
 
 
68
        if card and not main:
 
69
            names['main'] = card
 
70
            names['carda'] = None
 
71
 
 
72
        return names
 
73
 
 
74
    def linux_swap_drives(self, drives):
 
75
        if len(drives) < 2: return drives
 
76
        drives = list(drives)
 
77
        t = drives[0]
 
78
        drives[0] = drives[1]
 
79
        drives[1] = t
 
80
        return tuple(drives)
 
81
 
 
82
 
 
83
class BEBOOK_MINI(BEBOOK):
 
84
    name           = 'BeBook Mini driver'
 
85
    description    = _('Communicate with the BeBook Mini eBook reader.')
 
86
 
43
87
 
44
88
    VENDOR_ID   = [0x0492]
45
89
    PRODUCT_ID  = [0x8813]
46
 
    BCD         = [0x319]
 
90
    BCD         = [0x319]
47
91
 
48
92
    OSX_MAIN_MEM = 'BeBook Mini Internal Memory'
49
93
    OSX_CARD_MEM = 'BeBook Mini Storage Card'