From 470faaecc0360945369bcd76779b5c532174c838 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 26 Nov 2008 12:41:43 -0800 Subject: [PATCH] PRS 700 support --- installer/windows/calibre/calibre.mpi | 34 ++----------------- src/calibre/devices/__init__.py | 5 +-- src/calibre/devices/interface.py | 1 + src/calibre/devices/libusb.py | 4 +-- src/calibre/devices/prs500/driver.py | 1 + src/calibre/devices/prs505/driver.py | 12 ++++--- src/calibre/devices/prs700/__init__.py | 6 ++++ src/calibre/devices/prs700/driver.py | 15 ++++++++ src/calibre/devices/scanner.py | 5 +-- src/calibre/devices/usbobserver/usbobserver.c | 5 +-- src/calibre/linux.py | 6 ++-- src/calibre/web/feeds/recipes/nytimes.py | 2 +- 12 files changed, 49 insertions(+), 47 deletions(-) create mode 100644 src/calibre/devices/prs700/__init__.py create mode 100644 src/calibre/devices/prs700/driver.py diff --git a/installer/windows/calibre/calibre.mpi b/installer/windows/calibre/calibre.mpi index 2b9f98e7c3..50dc81dcbd 100644 --- a/installer/windows/calibre/calibre.mpi +++ b/installer/windows/calibre/calibre.mpi @@ -138,7 +138,7 @@ ProjectID DA98A0C6-9102-73EC-2516-B147E972D3F7 ProjectVersion -1.2.10.1 +1.2.7.0 SaveOnlyToplevelDirs No @@ -1100,9 +1100,6 @@ AAFE58A0-2DFB-CA20-1F6E-D3815F885996,Alias AIX-ppc,Active No -AIX-ppc,BuildSeparateArchives -No - AIX-ppc,DefaultDirectoryPermission 0755 @@ -1478,9 +1475,6 @@ FBA33088-C809-DD6B-D337-EADBF1CEE966,String FreeBSD-4-x86,Active No -FreeBSD-4-x86,BuildSeparateArchives -No - FreeBSD-4-x86,DefaultDirectoryPermission 0755 @@ -1532,9 +1526,6 @@ FreeBSD-4-x86,RootInstallDir FreeBSD-x86,Active No -FreeBSD-x86,BuildSeparateArchives -No - FreeBSD-x86,DefaultDirectoryPermission 0755 @@ -1586,9 +1577,6 @@ FreeBSD-x86,RootInstallDir HPUX-hppa,Active No -HPUX-hppa,BuildSeparateArchives -No - HPUX-hppa,DefaultDirectoryPermission 0755 @@ -1640,9 +1628,6 @@ HPUX-hppa,RootInstallDir Linux-x86,Active No -Linux-x86,BuildSeparateArchives -No - Linux-x86,DefaultDirectoryPermission 0755 @@ -1694,9 +1679,6 @@ Linux-x86,RootInstallDir Solaris-sparc,Active No -Solaris-sparc,BuildSeparateArchives -No - Solaris-sparc,DefaultDirectoryPermission 0755 @@ -1748,9 +1730,6 @@ Solaris-sparc,RootInstallDir TarArchive,Active No -TarArchive,BuildSeparateArchives -No - TarArchive,CompressionLevel 6 @@ -1811,15 +1790,9 @@ TarArchive,VirtualTextMap Windows,Active Yes -Windows,BuildSeparateArchives -No - Windows,Executable <%AppName%>-<%Version%><%Ext%> -Windows,FileDescription -{<%AppName%> <%Version%> Setup} - Windows,IncludeTWAPI Yes @@ -1856,9 +1829,6 @@ Windows,WindowsIcon ZipArchive,Active No -ZipArchive,BuildSeparateArchives -No - ZipArchive,CompressionLevel 6 @@ -1951,7 +1921,7 @@ E611105F-DC85-9E20-4F7B-E63C54E5DF06,Message 3EA07B17-04D8-6508-B535-96CC7173B49A,Message {<%AppName%> version <%Version%> created by Kovid Goyal -Please ensure that calibre is not running, as this will cause the installation to fail. Click Next to continue or Cancel to exit Setup.} +Please make sure that calibre is not running, as this will cause the install to fail. Click Next to continue or Cancel to exit Setup.} 442920D9-8A51-9476-14E4-787D5C230E84,Message <%UninstallCompleteText%> diff --git a/src/calibre/devices/__init__.py b/src/calibre/devices/__init__.py index 65bf4aa5fb..f2c89ea1c5 100644 --- a/src/calibre/devices/__init__.py +++ b/src/calibre/devices/__init__.py @@ -7,8 +7,9 @@ Device drivers. def devices(): from calibre.devices.prs500.driver import PRS500 from calibre.devices.prs505.driver import PRS505 - from calibre.devices.kindle.driver import KINDLE - return (PRS500, PRS505, KINDLE) + from calibre.devices.prs700.driver import PRS700 + #from calibre.devices.kindle.driver import KINDLE + return (PRS500, PRS505, PRS700) import time diff --git a/src/calibre/devices/interface.py b/src/calibre/devices/interface.py index 58a9eafa48..fb581e9545 100644 --- a/src/calibre/devices/interface.py +++ b/src/calibre/devices/interface.py @@ -20,6 +20,7 @@ class Device(object): FORMATS = ["lrf", "rtf", "pdf", "txt"] VENDOR_ID = 0x0000 PRODUCT_ID = 0x0000 + BCD = 0x0000 THUMBNAIL_HEIGHT = 68 # Height for thumbnails on device def __init__(self, key='-1', log_packets=False, report_progress=None) : diff --git a/src/calibre/devices/libusb.py b/src/calibre/devices/libusb.py index 1502772bf4..0bedce32bb 100644 --- a/src/calibre/devices/libusb.py +++ b/src/calibre/devices/libusb.py @@ -355,6 +355,6 @@ def get_devices(): for bus in buslist: devices = bus.device_list for dev in devices: - device = (dev.device_descriptor.idVendor, dev.device_descriptor.idProduct) + device = (dev.device_descriptor.idVendor, dev.device_descriptor.idProduct, dev.device_descriptor.bcdDevice) ans.append(device) - return ans \ No newline at end of file + return ans diff --git a/src/calibre/devices/prs500/driver.py b/src/calibre/devices/prs500/driver.py index 99e641e940..177f57b15f 100755 --- a/src/calibre/devices/prs500/driver.py +++ b/src/calibre/devices/prs500/driver.py @@ -85,6 +85,7 @@ class PRS500(Device): VENDOR_ID = 0x054c #: SONY Vendor Id PRODUCT_ID = 0x029b #: Product Id for the PRS-500 + BCD = 0x100 PRODUCT_NAME = 'PRS-500' VENDOR_NAME = 'SONY' INTERFACE_ID = 0 #: The interface we use to talk to the device diff --git a/src/calibre/devices/prs505/driver.py b/src/calibre/devices/prs505/driver.py index cc280c3eed..698a8f2a03 100644 --- a/src/calibre/devices/prs505/driver.py +++ b/src/calibre/devices/prs505/driver.py @@ -29,6 +29,7 @@ class File(object): class PRS505(Device): VENDOR_ID = 0x054c #: SONY Vendor Id PRODUCT_ID = 0x031e #: Product Id for the PRS-505 + BCD = 0x229 #: Needed to disambiguate 505 and 700 on linux PRODUCT_NAME = 'PRS-505' VENDOR_NAME = 'SONY' FORMATS = ['lrf', 'epub', "rtf", "pdf", "txt"] @@ -49,9 +50,11 @@ class PRS505(Device): - - %(main_memory)s - %(deviceclass)s + + + %(main_memory)s + %(deviceclass)s + @@ -81,6 +84,7 @@ class PRS505(Device): deviceclass=cls.__name__, vendor_id=hex(cls.VENDOR_ID), product_id=hex(cls.PRODUCT_ID), + bcd=hex(cls.BCD), main_memory=cls.MAIN_MEMORY_VOLUME_LABEL, storage_card=cls.STORAGE_CARD_VOLUME_LABEL, ) @@ -281,7 +285,7 @@ class PRS505(Device): self.report_progress = pr def get_device_information(self, end_session=True): - return ('PRS-505', '', '', '') + return (self.__class__.__name__, '', '', '') def card_prefix(self, end_session=True): return self._card_prefix diff --git a/src/calibre/devices/prs700/__init__.py b/src/calibre/devices/prs700/__init__.py new file mode 100644 index 0000000000..8ff060b0ee --- /dev/null +++ b/src/calibre/devices/prs700/__init__.py @@ -0,0 +1,6 @@ +__license__ = 'GPL v3' +__copyright__ = '2008, Kovid Goyal ' +''' +Device driver for the SONY PRS-700 +''' + diff --git a/src/calibre/devices/prs700/driver.py b/src/calibre/devices/prs700/driver.py new file mode 100644 index 0000000000..812ac0f911 --- /dev/null +++ b/src/calibre/devices/prs700/driver.py @@ -0,0 +1,15 @@ +__license__ = 'GPL v3' +__copyright__ = '2008, Kovid Goyal ' + +''' +Device driver for the SONY PRS-700 +''' + +from calibre.devices.prs505.driver import PRS505 + +class PRS700(PRS505): + + BCD = 0x31a + PRODUCT_NAME = 'PRS-700' + OSX_NAME = 'Sony PRS-700' + diff --git a/src/calibre/devices/scanner.py b/src/calibre/devices/scanner.py index ae14f06692..99a50020ec 100644 --- a/src/calibre/devices/scanner.py +++ b/src/calibre/devices/scanner.py @@ -47,9 +47,10 @@ class DeviceScanner(object): return True return False else: - for vendor, product in self.devices: + for vendor, product, bcdDevice in self.devices: if device.VENDOR_ID == vendor and device.PRODUCT_ID == product: - return True + if hasattr(device, 'BCD') and device.BCD == bcdDevice: + return True return False diff --git a/src/calibre/devices/usbobserver/usbobserver.c b/src/calibre/devices/usbobserver/usbobserver.c index 99fe39362d..20b4944d41 100644 --- a/src/calibre/devices/usbobserver/usbobserver.c +++ b/src/calibre/devices/usbobserver/usbobserver.c @@ -57,7 +57,7 @@ usbobserver_get_usb_devices(PyObject *self, PyObject *args) { IOCFPlugInInterface **plugInInterface = NULL; SInt32 score; IOUSBDeviceInterface182 **dev = NULL; - UInt16 vendor, product; + UInt16 vendor, product, bcd; PyObject *devices, *device; devices = PyList_New(0); @@ -80,7 +80,8 @@ usbobserver_get_usb_devices(PyObject *self, PyObject *args) { kr = (*dev)->GetDeviceVendor(dev, &vendor); kr = (*dev)->GetDeviceProduct(dev, &product); - device = Py_BuildValue("(ii)", vendor, product); + kr = (*dev)->GetDeviceReleaseNumber(dev, &bcd); + device = Py_BuildValue("(iii)", vendor, product, bcd); if (device == NULL) { IOObjectRelease(usbDevice); (*plugInInterface)->Release(plugInInterface); diff --git a/src/calibre/linux.py b/src/calibre/linux.py index 88b2a52ca7..f69b306b2b 100644 --- a/src/calibre/linux.py +++ b/src/calibre/linux.py @@ -338,12 +338,14 @@ def setup_udev_rules(group_file, reload, fatal_errors): - %(cls)s + + %(cls)s + '''%dict(cls=cls.__name__, vendor_id=cls.VENDOR_ID, product_id=cls.PRODUCT_ID, - prog=__appname__)) + prog=__appname__, bcd=cls.BCD)) fdi.write('\n'+cls.get_fdi()) fdi.write('\n\n') fdi.close() diff --git a/src/calibre/web/feeds/recipes/nytimes.py b/src/calibre/web/feeds/recipes/nytimes.py index 6f4caca134..43f0481e61 100644 --- a/src/calibre/web/feeds/recipes/nytimes.py +++ b/src/calibre/web/feeds/recipes/nytimes.py @@ -12,7 +12,7 @@ from lxml import html class NYTimesMobile(BasicNewsRecipe): - title = 'The New York Times (mobile)' + title = 'The New York Times' __author__ = 'Kovid Goyal' description = 'Daily news from the New York Times (mobile version)' timefmt = ' [%a, %d %b, %Y]'