From f054a3ea0c9c04fbf0f37f8eeb9bf8a6794361ac Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 12 Jul 2009 15:56:27 -0600 Subject: [PATCH 1/3] Fix job server on some versions of windows using invalid pipe address --- src/calibre/utils/ipc/server.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/calibre/utils/ipc/server.py b/src/calibre/utils/ipc/server.py index 70f77d7122..55da9c60ca 100644 --- a/src/calibre/utils/ipc/server.py +++ b/src/calibre/utils/ipc/server.py @@ -10,13 +10,14 @@ import os, cPickle, time, tempfile from math import ceil from threading import Thread, RLock from Queue import Queue, Empty -from multiprocessing.connection import Listener +from multiprocessing.connection import Listener, arbitrary_address from collections import deque from binascii import hexlify from calibre.utils.ipc.launch import Worker from calibre.utils.ipc.worker import PARALLEL_FUNCS from calibre import detect_ncpus as cpu_count +from calibre.constants import iswindows _counter = 0 @@ -91,7 +92,11 @@ class Server(Thread): self.pool_size = cpu_count() if pool_size is None else pool_size self.notify_on_job_done = notify_on_job_done self.auth_key = os.urandom(32) - self.listener = Listener(authkey=self.auth_key, backlog=4) + self.address = arbitrary_address('AF_PIPE' if iswindows else 'AF_UNIX') + if iswindows and self.address[1] == ':': + self.address = self.address[2:] + self.listener = Listener(address=self.address, + authkey=self.auth_key, backlog=4) self.add_jobs_queue, self.changed_jobs_queue = Queue(), Queue() self.kill_queue = Queue() self.waiting_jobs, self.processing_jobs = deque(), deque() From 04fe7ef6df3eabb3c446712b17dd563aecc00c2c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 12 Jul 2009 15:57:13 -0600 Subject: [PATCH 2/3] Driver for HTC Android phones --- installer/linux/freeze.py | 1 - src/calibre/customize/builtins.py | 3 +- src/calibre/devices/android/__init__.py | 10 +++++++ src/calibre/devices/android/driver.py | 38 +++++++++++++++++++++++++ src/calibre/devices/bebook/driver.py | 2 +- 5 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 src/calibre/devices/android/__init__.py create mode 100644 src/calibre/devices/android/driver.py diff --git a/installer/linux/freeze.py b/installer/linux/freeze.py index f6f7960658..a7430e1807 100644 --- a/installer/linux/freeze.py +++ b/installer/linux/freeze.py @@ -35,7 +35,6 @@ def freeze(): '/usr/lib/libpodofo.so.0.6.99', '/lib/libz.so.1', '/lib/libbz2.so.1', - '/lib/libbz2.so.1', '/usr/lib/libpoppler.so.4', '/usr/lib/libxml2.so.2', '/usr/lib/libdbus-1.so.3', diff --git a/src/calibre/customize/builtins.py b/src/calibre/customize/builtins.py index 389a34937f..de26365550 100644 --- a/src/calibre/customize/builtins.py +++ b/src/calibre/customize/builtins.py @@ -355,7 +355,7 @@ from calibre.devices.kindle.driver import KINDLE, KINDLE2, KINDLE_DX from calibre.devices.prs500.driver import PRS500 from calibre.devices.prs505.driver import PRS505 from calibre.devices.prs700.driver import PRS700 - +from calibre.devices.android.driver import ANDROID plugins = [HTML2ZIP] plugins += [ @@ -402,6 +402,7 @@ plugins += [ PRS500, PRS505, PRS700, + ANDROID, ] plugins += [x for x in list(locals().values()) if isinstance(x, type) and \ x.__name__.endswith('MetadataReader')] diff --git a/src/calibre/devices/android/__init__.py b/src/calibre/devices/android/__init__.py new file mode 100644 index 0000000000..3d1a86922e --- /dev/null +++ b/src/calibre/devices/android/__init__.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python +# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai +from __future__ import with_statement + +__license__ = 'GPL v3' +__copyright__ = '2009, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + + + diff --git a/src/calibre/devices/android/driver.py b/src/calibre/devices/android/driver.py new file mode 100644 index 0000000000..dafd67a4ad --- /dev/null +++ b/src/calibre/devices/android/driver.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python +# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai +from __future__ import with_statement + +__license__ = 'GPL v3' +__copyright__ = '2009, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + + +from calibre.devices.usbms.driver import USBMS + +class ANDROID(USBMS): + name = 'Android driver' + description = _('Communicate with Android phones.') + author = 'Kovid Goyal' + supported_platforms = ['windows', 'osx', 'linux'] + + + # Ordered list of supported formats + FORMATS = ['epub'] + + VENDOR_ID = [ + 0x0bb4, + ] + PRODUCT_ID = [0x0c02] + BCD = [0x100] + EBOOK_DIR_MAIN = 'wordplayer/calibre' + + VENDOR_NAME = 'HTC' + WINDOWS_MAIN_MEM = 'ANDROID_PHONE' + + OSX_MAIN_MEM = 'HTC Android Phone Media' + + MAIN_MEMORY_VOLUME_LABEL = 'Android Internal Memory' + + SUPPORTS_SUB_DIRS = True + + diff --git a/src/calibre/devices/bebook/driver.py b/src/calibre/devices/bebook/driver.py index dacce1ba31..e8bfece554 100644 --- a/src/calibre/devices/bebook/driver.py +++ b/src/calibre/devices/bebook/driver.py @@ -12,7 +12,7 @@ from calibre.devices.usbms.driver import USBMS class BEBOOK(USBMS): name = 'BeBook driver' description = _('Communicate with the BeBook eBook reader.') - author = _('Tijmen Ruizendaal') + author = 'Tijmen Ruizendaal' supported_platforms = ['windows', 'osx', 'linux'] From 37dc3b72be9f2a024c0aa720886d0b58b2e092ef Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 12 Jul 2009 16:24:02 -0600 Subject: [PATCH 3/3] Add support for Android+WordPlayer to welcome wizard --- src/calibre/gui2/wizard/__init__.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/calibre/gui2/wizard/__init__.py b/src/calibre/gui2/wizard/__init__.py index 29ceda68fd..d73c245288 100644 --- a/src/calibre/gui2/wizard/__init__.py +++ b/src/calibre/gui2/wizard/__init__.py @@ -113,6 +113,13 @@ class iPhone(Device): manufacturer = 'Apple' id = 'iphone' +class Android(Device): + + name = 'Adroid phone + WordPlayer' + output_format = 'EPUB' + manufacturer = 'Google/HTC' + id = 'android' + class Hanlin(Device): name = 'Hanlin V3' @@ -263,7 +270,21 @@ class StanzaPage(QWizardPage, StanzaUI): except: continue +class WordPlayerPage(StanzaPage): + ID = 6 + + def __init__(self): + StanzaPage.__init__(self) + self.label.setText('

'+_('If you use the WordPlayer e-book app on ' + 'your Android phone, you can access your calibre book collection ' + 'directly on the device. To do this you have to turn on the ' + 'content server.')) + self.instructions.setText('

'+_('Remember to leave calibre running ' + 'as the server only runs as long as calibre is running.')+'

' + + _('You have to add the URL http://myhostname:8080 as your ' + 'calibre library in WordPlayer. Here myhostname should be the fully ' + 'qualified hostname or the IP address of the computer calibre is running on.')) class DevicePage(QWizardPage, DeviceUI): @@ -324,6 +345,8 @@ class DevicePage(QWizardPage, DeviceUI): return KindlePage.ID if dev is iPhone: return StanzaPage.ID + if dev is Android: + return WordPlayerPage.ID return FinishPage.ID class MoveMonitor(QObject): @@ -493,11 +516,13 @@ class Wizard(QWizard): self.finish_page.finish_text.setText(t%bt) self.kindle_page = KindlePage() self.stanza_page = StanzaPage() + self.word_player_page = WordPlayerPage() self.setPage(self.library_page.ID, self.library_page) self.setPage(self.device_page.ID, self.device_page) self.setPage(self.finish_page.ID, self.finish_page) self.setPage(self.kindle_page.ID, self.kindle_page) self.setPage(self.stanza_page.ID, self.stanza_page) + self.setPage(self.word_player_page.ID, self.word_player_page) self.device_extra_page = None nh, nw = min_available_height()-75, available_width()-30