1# -*- coding: utf-8 -*- 2 3 4__license__ = 'GPL v3' 5__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>' 6__docformat__ = 'restructuredtext en' 7 8''' 9Device driver for the Netronix EB600 10 11Windows PNP strings: 12 ('USBSTOR\\DISK&VEN_NETRONIX&PROD_EBOOK&REV_062E\\6&1A275569&0&EB6001009 132W00000&0', 2, u'F:\\') 14 ('USBSTOR\\DISK&VEN_NETRONIX&PROD_EBOOK&REV_062E\\6&1A275569&0&EB6001009 152W00000&1', 3, u'G:\\') 16 17''' 18import re 19 20from calibre.devices.usbms.driver import USBMS 21 22 23class EB600(USBMS): 24 25 name = 'Netronix EB600 Device Interface' 26 gui_name = 'Netronix EB600' 27 description = _('Communicate with the EB600 e-book reader.') 28 author = 'Kovid Goyal' 29 supported_platforms = ['windows', 'osx', 'linux'] 30 31 # Ordered list of supported formats 32 FORMATS = ['epub', 'mobi', 'prc', 'chm', 'djvu', 'html', 'rtf', 'txt', 33 'pdf'] 34 DRM_FORMATS = ['prc', 'mobi', 'html', 'pdf', 'txt'] 35 36 VENDOR_ID = [0x1f85] 37 PRODUCT_ID = [0x1688] 38 BCD = [0x110] 39 40 VENDOR_NAME = ['NETRONIX', 'WOLDER', 'MD86371'] 41 WINDOWS_MAIN_MEM = ['EBOOK', 'MIBUK_GAMMA_6.2', 'MD86371'] 42 WINDOWS_CARD_A_MEM = ['EBOOK', 'MD86371'] 43 44 OSX_MAIN_MEM = 'EB600 Internal Storage Media' 45 OSX_CARD_A_MEM = 'EB600 Card Storage Media' 46 47 MAIN_MEMORY_VOLUME_LABEL = 'EB600 Main Memory' 48 STORAGE_CARD_VOLUME_LABEL = 'EB600 Storage Card' 49 50 EBOOK_DIR_MAIN = '' 51 EBOOK_DIR_CARD_A = '' 52 SUPPORTS_SUB_DIRS = True 53 54 55class TOLINO(EB600): 56 57 name = 'Tolino Shine Device Interface' 58 gui_name = 'tolino shine' 59 description = _('Communicate with the tolino shine and vision readers') 60 FORMATS = ['epub', 'pdf', 'txt'] 61 62 EPOS_PRODUCT_ID = [0x6053] 63 VISION6_PRODUCT_ID = [0x8000] 64 OTHER_TOLINO_PRODUCT_ID = [0x6033, 0x6052] 65 PRODUCT_ID = EB600.PRODUCT_ID + OTHER_TOLINO_PRODUCT_ID + EPOS_PRODUCT_ID + VISION6_PRODUCT_ID 66 67 KOBO_VENDOR_ID = [0x4173] # Some newer Tolino devices have the Kobo Vendor ID. But, they still use different software. 68 VENDOR_ID = EB600.VENDOR_ID + KOBO_VENDOR_ID 69 BCD = [0x226, 0x9999] 70 VENDOR_NAME = ['DEUTSCHE', 'LINUX'] 71 WINDOWS_MAIN_MEM = WINDOWS_CARD_A_MEM = ['_TELEKOMTOLINO', 'FILE-CD_GADGET'] 72 EBOOK_DIR_MAIN = '' 73 74 EXTRA_CUSTOMIZATION_MESSAGE = [ 75 _('Swap main and card A') + 76 ':::' + 77 _('Check this box if the device\'s main memory is being seen as card a and the card ' 78 'is being seen as main memory. Some tolino devices may need this option.'), 79 ] 80 81 EXTRA_CUSTOMIZATION_DEFAULT = [ 82 True, 83 ] 84 85 OPT_SWAP_MEMORY = 0 86 87 def get_device_information(self, end_session=True): 88 self.set_device_name() 89 return super(TOLINO, self).get_device_information(end_session) 90 91 # There are apparently two versions of this device, one with swapped 92 # drives and one without, see https://bugs.launchpad.net/bugs/1240504 93 def linux_swap_drives(self, drives): 94 e = self.settings().extra_customization 95 if len(drives) < 2 or not drives[0] or not drives[1] or not e[self.OPT_SWAP_MEMORY]: 96 return drives 97 drives = list(drives) 98 t = drives[0] 99 drives[0] = drives[1] 100 drives[1] = t 101 return tuple(drives) 102 103 def windows_sort_drives(self, drives): 104 e = self.settings().extra_customization 105 if len(drives) < 2 or not e[self.OPT_SWAP_MEMORY]: 106 return drives 107 main = drives.get('main', None) 108 carda = drives.get('carda', None) 109 if main and carda: 110 drives['main'] = carda 111 drives['carda'] = main 112 return drives 113 114 def osx_sort_names(self, names): 115 e = self.settings().extra_customization 116 if len(names) < 2 or not e[self.OPT_SWAP_MEMORY]: 117 return names 118 main = names.get('main', None) 119 card = names.get('carda', None) 120 121 if main is not None and card is not None: 122 names['main'] = card 123 names['carda'] = main 124 125 return names 126 127 def post_open_callback(self): 128 # The tolino vision only handles books inside the Books folder 129 product_id, bcd = self.device_being_opened[1], self.device_being_opened[2] 130 is_tolino = product_id in (0x6033, 0x6052, 0x6053) or (product_id == 0x1688 and bcd == 0x226) 131 self.ebook_dir_for_upload = 'Books' if is_tolino else '' 132 133 def get_main_ebook_dir(self, for_upload=False): 134 if for_upload: 135 return getattr(self, 'ebook_dir_for_upload', self.EBOOK_DIR_MAIN) 136 return self.EBOOK_DIR_MAIN 137 138 def isEpos(self): 139 return self.detected_device.idProduct in self.EPOS_PRODUCT_ID 140 141 def isVision6(self): 142 return self.detected_device.idProduct in self.VISION6_PRODUCT_ID 143 144 def set_device_name(self): 145 device_name = self.gui_name 146 if self.isEpos(): 147 device_name = 'tolino epos' 148 elif self.isVision6(): 149 device_name = 'tolino vision 6' 150 self.__class__.gui_name = device_name 151 return device_name 152 153 154class COOL_ER(EB600): 155 156 name = 'Cool-er device interface' 157 gui_name = 'Cool-er' 158 159 FORMATS = ['epub', 'mobi', 'prc', 'pdf', 'txt'] 160 161 VENDOR_NAME = 'COOL-ER' 162 WINDOWS_MAIN_MEM = WINDOWS_CARD_A_MEM = 'EREADER' 163 164 OSX_MAIN_MEM = 'COOL-ER eReader Media' 165 166 EBOOK_DIR_MAIN = 'my docs' 167 168 169class SHINEBOOK(EB600): 170 171 name = 'ShineBook device Interface' 172 173 gui_name = 'ShineBook' 174 175 FORMATS = ['epub', 'prc', 'rtf', 'pdf', 'txt'] 176 177 VENDOR_NAME = 'LONGSHIN' 178 WINDOWS_MAIN_MEM = 'ESHINEBOOK' 179 MAIN_MEMORY_VOLUME_LABEL = 'ShineBook Main Memory' 180 STORAGE_CARD_VOLUME_LABEL = 'ShineBook Storage Card' 181 182 @classmethod 183 def can_handle(cls, dev, debug=False): 184 return dev[4] == 'ShineBook' 185 186 187class POCKETBOOK360(EB600): 188 189 # Device info on OS X 190 # (8069L, 5768L, 272L, u'', u'', u'1.00') 191 192 name = 'PocketBook 360 Device Interface' 193 194 gui_name = 'PocketBook 360' 195 VENDOR_ID = [0x1f85, 0x525] 196 PRODUCT_ID = [0x1688, 0xa4a5] 197 BCD = [0x110] 198 199 FORMATS = ['epub', 'fb2', 'prc', 'mobi', 'pdf', 'djvu', 'rtf', 'chm', 'txt'] 200 201 VENDOR_NAME = ['PHILIPS', '__POCKET', 'POCKETBO'] 202 WINDOWS_MAIN_MEM = WINDOWS_CARD_A_MEM = ['MASS_STORGE', 'BOOK_USB_STORAGE', 203 'OK_POCKET_611_61', 'OK_POCKET_360+61'] 204 205 OSX_MAIN_MEM = OSX_CARD_A_MEM = 'Philips Mass Storge Media' 206 OSX_MAIN_MEM_VOL_PAT = re.compile(r'/Pocket') 207 208 @classmethod 209 def can_handle(cls, dev, debug=False): 210 return dev[-1] == '1.00' and not dev[-2] and not dev[-3] 211 212 213class POCKETBOOKHD(EB600): 214 215 name = 'Pocket Touch HD Device Interface' 216 gui_name = 'PocketBook HD' 217 PRODUCT_ID = [0x6a42] 218 BCD = [0x9999] 219 FORMATS = ['epub', 'fb2', 'prc', 'mobi', 'docx', 'doc', 'pdf', 'djvu', 'rtf', 'chm', 'txt'] 220 221 222class GER2(EB600): 223 224 name = 'Ganaxa GeR2 Device Interface' 225 gui_name = 'Ganaxa GeR2' 226 227 FORMATS = ['pdf'] 228 229 VENDOR_ID = [0x3034] 230 PRODUCT_ID = [0x1795] 231 BCD = [0x132] 232 233 VENDOR_NAME = 'GANAXA' 234 WINDOWS_MAIN_MEN = 'GER2_________-FD' 235 WINDOWS_CARD_A_MEM = 'GER2_________-SD' 236 237 238class ITALICA(EB600): 239 240 name = 'Italica Device Interface' 241 gui_name = 'Italica' 242 icon = I('devices/italica.png') 243 244 FORMATS = ['epub', 'rtf', 'fb2', 'html', 'prc', 'mobi', 'pdf', 'txt'] 245 246 VENDOR_NAME = 'ITALICA' 247 WINDOWS_MAIN_MEM = 'EREADER' 248 WINDOWS_CARD_A_MEM = WINDOWS_MAIN_MEM 249 250 OSX_MAIN_MEM = 'Italica eReader Media' 251 OSX_CARD_A_MEM = OSX_MAIN_MEM 252 253 MAIN_MEMORY_VOLUME_LABEL = 'Italica Main Memory' 254 STORAGE_CARD_VOLUME_LABEL = 'Italica Storage Card' 255 256 257class ECLICTO(EB600): 258 259 name = 'eClicto Device Interface' 260 gui_name = 'eClicto' 261 262 FORMATS = ['epub', 'pdf', 'htm', 'html', 'txt'] 263 264 VENDOR_NAME = 'ECLICTO' 265 WINDOWS_MAIN_MEM = 'EBOOK' 266 WINDOWS_CARD_A_MEM = 'EBOOK' 267 268 EBOOK_DIR_MAIN = 'Text' 269 EBOOK_DIR_CARD_A = '' 270 271 272class DBOOK(EB600): 273 274 name = 'Airis Dbook Device Interface' 275 gui_name = 'Airis Dbook' 276 277 FORMATS = ['epub', 'mobi', 'prc', 'fb2', 'html', 'pdf', 'rtf', 'txt'] 278 279 VENDOR_NAME = 'INFINITY' 280 WINDOWS_MAIN_MEM = 'AIRIS_DBOOK' 281 WINDOWS_CARD_A_MEM = 'AIRIS_DBOOK' 282 283 284class INVESBOOK(EB600): 285 286 name = 'Inves Book Device Interface' 287 gui_name = 'Inves Book 600' 288 289 FORMATS = ['epub', 'mobi', 'prc', 'fb2', 'html', 'pdf', 'rtf', 'txt'] 290 BCD = [0x110, 0x323] 291 292 VENDOR_NAME = ['INVES_E6', 'INVES-WI', 'POCKETBO'] 293 WINDOWS_MAIN_MEM = WINDOWS_CARD_A_MEM = ['00INVES_E600', 'INVES-WIBOOK', 294 'OK_POCKET_611_61'] 295 296 297class BOOQ(EB600): 298 name = 'Booq Device Interface' 299 gui_name = 'bq Reader' 300 301 FORMATS = ['epub', 'mobi', 'prc', 'fb2', 'pdf', 'doc', 'rtf', 'txt', 'html'] 302 303 VENDOR_NAME = ['NETRONIX', '36LBOOKS'] 304 WINDOWS_MAIN_MEM = WINDOWS_CARD_A_MEM = ['EB600', 'ELEQTOR'] 305 306 307class MENTOR(EB600): 308 309 name = 'Astak Mentor EB600' 310 gui_name = 'Mentor' 311 description = _('Communicate with the Astak Mentor EB600') 312 FORMATS = ['epub', 'fb2', 'mobi', 'prc', 'pdf', 'txt'] 313 314 WINDOWS_MAIN_MEM = WINDOWS_CARD_A_MEM = 'MENTOR' 315 316 317class ELONEX(EB600): 318 319 name = 'Elonex 600EB' 320 gui_name = 'Elonex' 321 322 FORMATS = ['epub', 'pdf', 'txt', 'html'] 323 324 VENDOR_NAME = 'ELONEX' 325 WINDOWS_MAIN_MEM = 'EBOOK' 326 WINDOWS_CARD_A_MEM = 'EBOOK' 327 328 @classmethod 329 def can_handle(cls, dev, debug=False): 330 return dev[3] == 'Elonex' and dev[4] == 'eBook' 331 332 333class POCKETBOOK301(USBMS): 334 335 name = 'PocketBook 301 Device Interface' 336 description = _('Communicate with the PocketBook 301 Reader.') 337 author = 'Kovid Goyal' 338 supported_platforms = ['windows', 'osx', 'linux'] 339 FORMATS = ['epub', 'fb2', 'prc', 'mobi', 'pdf', 'djvu', 'rtf', 'chm', 'txt'] 340 341 SUPPORTS_SUB_DIRS = True 342 343 MAIN_MEMORY_VOLUME_LABEL = 'PocketBook 301 Main Memory' 344 STORAGE_CARD_VOLUME_LABEL = 'PocketBook 301 Storage Card' 345 346 VENDOR_ID = [0x1] 347 PRODUCT_ID = [0x301] 348 BCD = [0x132] 349 350 351class POCKETBOOK602(USBMS): 352 353 name = 'PocketBook Pro 602/902 Device Interface' 354 gui_name = 'PocketBook' 355 description = _('Communicate with the PocketBook 515/602/603/902/903/Pro 912 reader.') 356 author = 'Kovid Goyal' 357 supported_platforms = ['windows', 'osx', 'linux'] 358 FORMATS = ['epub', 'fb2', 'prc', 'mobi', 'pdf', 'djvu', 'rtf', 'chm', 359 'doc', 'tcr', 'txt'] 360 361 EBOOK_DIR_MAIN = 'books' 362 SUPPORTS_SUB_DIRS = True 363 SCAN_FROM_ROOT = True 364 365 VENDOR_ID = [0x0525] 366 PRODUCT_ID = [0xa4a5] 367 BCD = [0x0324, 0x0330, 0x0399] 368 369 VENDOR_NAME = ['', 'LINUX'] 370 WINDOWS_MAIN_MEM = WINDOWS_CARD_A_MEM = ['PB602', 'PB603', 'PB902', 371 'PB903', 'Pocket912', 'PB', 'FILE-STOR_GADGET'] 372 373 374class POCKETBOOK622(POCKETBOOK602): 375 376 name = 'PocketBook 622 Device Interface' 377 description = _('Communicate with the PocketBook 622 and 623 readers.') 378 EBOOK_DIR_MAIN = '' 379 380 VENDOR_ID = [0x0489] 381 PRODUCT_ID = [0xe107, 0xcff1] 382 BCD = [0x0326] 383 384 VENDOR_NAME = 'LINUX' 385 WINDOWS_MAIN_MEM = WINDOWS_CARD_A_MEM = 'FILE-STOR_GADGET' 386 387 388class POCKETBOOK360P(POCKETBOOK602): 389 390 name = 'PocketBook 360+ Device Interface' 391 description = _('Communicate with the PocketBook 360+ reader.') 392 BCD = [0x0323] 393 EBOOK_DIR_MAIN = '' 394 395 VENDOR_NAME = '__POCKET' 396 WINDOWS_MAIN_MEM = WINDOWS_CARD_A_MEM = 'BOOK_USB_STORAGE' 397 398 399class POCKETBOOK701(USBMS): 400 401 name = 'PocketBook 701 Device Interface' 402 gui_name = 'PocketBook' 403 description = _('Communicate with the PocketBook 701') 404 author = _('Kovid Goyal') 405 406 supported_platforms = ['windows', 'osx', 'linux'] 407 FORMATS = ['epub', 'fb2', 'prc', 'mobi', 'pdf', 'djvu', 'rtf', 'chm', 408 'doc', 'tcr', 'txt'] 409 410 EBOOK_DIR_MAIN = 'books' 411 SUPPORTS_SUB_DIRS = True 412 413 VENDOR_ID = [0x18d1] 414 PRODUCT_ID = [0xa004] 415 BCD = [0x0224] 416 417 VENDOR_NAME = 'ANDROID' 418 WINDOWS_MAIN_MEM = WINDOWS_CARD_A_MEM = '__UMS_COMPOSITE' 419 420 def windows_sort_drives(self, drives): 421 if len(drives) < 2: 422 return drives 423 main = drives.get('main', None) 424 carda = drives.get('carda', None) 425 if main and carda: 426 drives['main'] = carda 427 drives['carda'] = main 428 return drives 429 430 431class POCKETBOOK740(USBMS): 432 433 name = 'PocketBook 701 Device Interface' 434 gui_name = 'PocketBook' 435 description = _('Communicate with the PocketBook 740') 436 supported_platforms = ['windows', 'osx', 'linux'] 437 FORMATS = ['epub', 'fb2', 'prc', 'mobi', 'pdf', 'djvu', 'rtf', 'chm', 438 'doc', 'tcr', 'txt'] 439 EBOOK_DIR_MAIN = 'books' 440 SUPPORTS_SUB_DIRS = True 441 SCAN_FROM_ROOT = True 442 443 VENDOR_ID = [0x18d1] 444 PRODUCT_ID = [0x0001] 445 BCD = [0x0101] 446 447 448class PI2(EB600): 449 450 name = 'Infibeam Pi2 Device Interface' 451 gui_name = 'Infibeam Pi2' 452 author = 'Michael Scalet' 453 description = _('Communicate with the Infibeam Pi2 reader.') 454 version = (1,0,1) 455 456 # Ordered list of supported formats 457 FORMATS = ['epub', 'mobi', 'prc', 'html', 'htm', 'doc', 'pdf', 'rtf', 458 'txt'] 459 460 VENDOR_NAME = 'INFIBEAM' 461 WINDOWS_MAIN_MEM = 'INFIBEAM_PI' 462 WINDOWS_CARD_A_MEM = 'INFIBEAM_PI' 463 464 DELETE_EXTS = ['.rec'] 465