mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-11 09:13:57 -04:00
Enable Qt SSL in the calibre windows build and a couple of fixes for the overdrive plugin
This commit is contained in:
parent
2b21ea3d9b
commit
cbe800e423
@ -13,7 +13,8 @@ from setup import Command, modules, functions, basenames, __version__, \
|
|||||||
from setup.build_environment import msvc, MT, RC
|
from setup.build_environment import msvc, MT, RC
|
||||||
from setup.installer.windows.wix import WixMixIn
|
from setup.installer.windows.wix import WixMixIn
|
||||||
|
|
||||||
QT_DIR = 'Q:\\Qt\\4.7.1'
|
OPENSSL_DIR = r'Q:\openssl'
|
||||||
|
QT_DIR = 'Q:\\Qt\\4.7.2'
|
||||||
QT_DLLS = ['Core', 'Gui', 'Network', 'Svg', 'WebKit', 'Xml', 'XmlPatterns']
|
QT_DLLS = ['Core', 'Gui', 'Network', 'Svg', 'WebKit', 'Xml', 'XmlPatterns']
|
||||||
LIBUSB_DIR = 'C:\\libusb'
|
LIBUSB_DIR = 'C:\\libusb'
|
||||||
LIBUNRAR = 'C:\\Program Files\\UnrarDLL\\unrar.dll'
|
LIBUNRAR = 'C:\\Program Files\\UnrarDLL\\unrar.dll'
|
||||||
@ -108,6 +109,8 @@ class Win32Freeze(Command, WixMixIn):
|
|||||||
self.dll_dir = self.j(self.base, 'DLLs')
|
self.dll_dir = self.j(self.base, 'DLLs')
|
||||||
shutil.copytree(r'C:\Python%s\DLLs'%self.py_ver, self.dll_dir,
|
shutil.copytree(r'C:\Python%s\DLLs'%self.py_ver, self.dll_dir,
|
||||||
ignore=shutil.ignore_patterns('msvc*.dll', 'Microsoft.*'))
|
ignore=shutil.ignore_patterns('msvc*.dll', 'Microsoft.*'))
|
||||||
|
for x in glob.glob(self.j(OPENSSL_DIR, 'bin', '*.dll')):
|
||||||
|
shutil.copy2(x, self.dll_dir)
|
||||||
for x in QT_DLLS:
|
for x in QT_DLLS:
|
||||||
x += '4.dll'
|
x += '4.dll'
|
||||||
if not x.startswith('phonon'): x = 'Qt'+x
|
if not x.startswith('phonon'): x = 'Qt'+x
|
||||||
|
@ -53,12 +53,25 @@ SQLite
|
|||||||
|
|
||||||
Put sqlite3*.h from the sqlite windows amlgamation in ~/sw/include
|
Put sqlite3*.h from the sqlite windows amlgamation in ~/sw/include
|
||||||
|
|
||||||
|
OpenSSL
|
||||||
|
--------
|
||||||
|
|
||||||
|
First install ActiveState Perl if you dont already have perl in windows
|
||||||
|
Download and untar the openssl tarball, follow the instructions in INSTALL.W32 (use no-asm)
|
||||||
|
to install use prefix q:\openssl
|
||||||
|
|
||||||
|
perl Configure VC-WIN32 no-asm enable-static-engine --prefix=Q:/openssl
|
||||||
|
ms\do_ms.bat
|
||||||
|
nmake -f ms\ntdll.mak
|
||||||
|
nmake -f ms\ntdll.mak test
|
||||||
|
nmake -f ms\ntdll.mak install
|
||||||
|
|
||||||
Qt
|
Qt
|
||||||
--------
|
--------
|
||||||
|
|
||||||
Extract Qt sourcecode to C:\Qt\4.x.x. Run configure and make::
|
Extract Qt sourcecode to C:\Qt\4.x.x. Run configure and make::
|
||||||
|
|
||||||
configure -opensource -release -qt-zlib -qt-gif -qt-libmng -qt-libpng -qt-libtiff -qt-libjpeg -release -platform win32-msvc2008 -no-qt3support -webkit -xmlpatterns -no-phonon -no-style-plastique -no-style-cleanlooks -no-style-motif -no-style-cde -no-declarative -no-scripttools -no-audio-backend -no-multimedia -no-dbus -no-openvg -no-opengl -no-qt3support -confirm-license -nomake examples -nomake demos -nomake docs && nmake
|
configure -opensource -release -qt-zlib -qt-gif -qt-libmng -qt-libpng -qt-libtiff -qt-libjpeg -release -platform win32-msvc2008 -no-qt3support -webkit -xmlpatterns -no-phonon -no-style-plastique -no-style-cleanlooks -no-style-motif -no-style-cde -no-declarative -no-scripttools -no-audio-backend -no-multimedia -no-dbus -no-openvg -no-opengl -no-qt3support -confirm-license -nomake examples -nomake demos -nomake docs -openssl -I Q:\openssl\include -L Q:\openssl\lib && nmake
|
||||||
|
|
||||||
SIP
|
SIP
|
||||||
-----
|
-----
|
||||||
|
@ -9,7 +9,7 @@ __docformat__ = 'restructuredtext en'
|
|||||||
'''
|
'''
|
||||||
Fetch metadata using Overdrive Content Reserve
|
Fetch metadata using Overdrive Content Reserve
|
||||||
'''
|
'''
|
||||||
import re, random, mechanize, copy
|
import re, random, mechanize, copy, json
|
||||||
from threading import RLock
|
from threading import RLock
|
||||||
from Queue import Queue, Empty
|
from Queue import Queue, Empty
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ class OverDrive(Source):
|
|||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
Source.__init__(self, *args, **kwargs)
|
Source.__init__(self, *args, **kwargs)
|
||||||
self.prefs.defaults['ignore_fields'] =['tags', 'pubdate', 'comments', 'identifier:isbn', 'language']
|
self.prefs.defaults['ignore_fields'] =['tags', 'pubdate', 'comments', 'identifier:isbn']
|
||||||
|
|
||||||
def identify(self, log, result_queue, abort, title=None, authors=None, # {{{
|
def identify(self, log, result_queue, abort, title=None, authors=None, # {{{
|
||||||
identifiers={}, timeout=30):
|
identifiers={}, timeout=30):
|
||||||
@ -228,7 +228,7 @@ class OverDrive(Source):
|
|||||||
def sort_ovrdrv_results(self, raw, title=None, title_tokens=None, author=None, author_tokens=None, ovrdrv_id=None):
|
def sort_ovrdrv_results(self, raw, title=None, title_tokens=None, author=None, author_tokens=None, ovrdrv_id=None):
|
||||||
close_matches = []
|
close_matches = []
|
||||||
raw = re.sub('.*?\[\[(?P<content>.*?)\]\].*', '[[\g<content>]]', raw)
|
raw = re.sub('.*?\[\[(?P<content>.*?)\]\].*', '[[\g<content>]]', raw)
|
||||||
results = eval(raw)
|
results = json.loads(raw)
|
||||||
#print results
|
#print results
|
||||||
# The search results are either from a keyword search or a multi-format list from a single ID,
|
# The search results are either from a keyword search or a multi-format list from a single ID,
|
||||||
# sort through the results for closest match/format
|
# sort through the results for closest match/format
|
||||||
@ -392,7 +392,9 @@ class OverDrive(Source):
|
|||||||
from calibre.utils.date import parse_date
|
from calibre.utils.date import parse_date
|
||||||
mi.pubdate = parse_date(pub_date[0].strip())
|
mi.pubdate = parse_date(pub_date[0].strip())
|
||||||
if lang:
|
if lang:
|
||||||
mi.language = lang[0].strip()
|
lang = lang[0].strip().lower()
|
||||||
|
mi.language = {'english':'en', 'french':'fr', 'german':'de',
|
||||||
|
'spanish':'es'}.get(lang, None)
|
||||||
|
|
||||||
if ebook_isbn:
|
if ebook_isbn:
|
||||||
#print "ebook isbn is "+str(ebook_isbn[0])
|
#print "ebook isbn is "+str(ebook_isbn[0])
|
||||||
|
@ -28,15 +28,15 @@ from calibre.utils.config import DynamicConfig
|
|||||||
from calibre.utils.icu import sort_key
|
from calibre.utils.icu import sort_key
|
||||||
|
|
||||||
class MobileReadStore(BasicStoreConfig, StorePlugin):
|
class MobileReadStore(BasicStoreConfig, StorePlugin):
|
||||||
|
|
||||||
def genesis(self):
|
def genesis(self):
|
||||||
self.config = DynamicConfig('store_' + self.name)
|
self.config = DynamicConfig('store_' + self.name)
|
||||||
self.rlock = RLock()
|
self.rlock = RLock()
|
||||||
|
|
||||||
def open(self, parent=None, detail_item=None, external=False):
|
def open(self, parent=None, detail_item=None, external=False):
|
||||||
settings = self.get_settings()
|
settings = self.get_settings()
|
||||||
url = 'http://www.mobileread.com/'
|
url = 'http://www.mobileread.com/'
|
||||||
|
|
||||||
if external or settings.get(self.name + '_open_external', False):
|
if external or settings.get(self.name + '_open_external', False):
|
||||||
open_url(QUrl(detail_item if detail_item else url))
|
open_url(QUrl(detail_item if detail_item else url))
|
||||||
else:
|
else:
|
||||||
@ -71,7 +71,7 @@ class MobileReadStore(BasicStoreConfig, StorePlugin):
|
|||||||
ratio += s.ratio()
|
ratio += s.ratio()
|
||||||
if ratio > 0:
|
if ratio > 0:
|
||||||
matches.append((ratio, x))
|
matches.append((ratio, x))
|
||||||
|
|
||||||
# Move the best scorers to head of list.
|
# Move the best scorers to head of list.
|
||||||
matches = heapq.nlargest(max_results, matches)
|
matches = heapq.nlargest(max_results, matches)
|
||||||
for score, book in matches:
|
for score, book in matches:
|
||||||
@ -81,21 +81,21 @@ class MobileReadStore(BasicStoreConfig, StorePlugin):
|
|||||||
def update_book_list(self, timeout=10):
|
def update_book_list(self, timeout=10):
|
||||||
with self.rlock:
|
with self.rlock:
|
||||||
url = 'http://www.mobileread.com/forums/ebooks.php?do=getlist&type=html'
|
url = 'http://www.mobileread.com/forums/ebooks.php?do=getlist&type=html'
|
||||||
|
|
||||||
last_download = self.config.get(self.name + '_last_download', None)
|
last_download = self.config.get(self.name + '_last_download', None)
|
||||||
# Don't update the book list if our cache is less than one week old.
|
# Don't update the book list if our cache is less than one week old.
|
||||||
if last_download and (time.time() - last_download) < 604800:
|
if last_download and (time.time() - last_download) < 604800:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Download the book list HTML file from MobileRead.
|
# Download the book list HTML file from MobileRead.
|
||||||
br = browser()
|
br = browser()
|
||||||
raw_data = None
|
raw_data = None
|
||||||
with closing(br.open(url, timeout=timeout)) as f:
|
with closing(br.open(url, timeout=timeout)) as f:
|
||||||
raw_data = f.read()
|
raw_data = f.read()
|
||||||
|
|
||||||
if not raw_data:
|
if not raw_data:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Turn books listed in the HTML file into BookRef's.
|
# Turn books listed in the HTML file into BookRef's.
|
||||||
books = []
|
books = []
|
||||||
try:
|
try:
|
||||||
@ -105,7 +105,7 @@ class MobileReadStore(BasicStoreConfig, StorePlugin):
|
|||||||
book.detail_item = ''.join(book_data.xpath('.//a/@href'))
|
book.detail_item = ''.join(book_data.xpath('.//a/@href'))
|
||||||
book.format = ''.join(book_data.xpath('.//i/text()'))
|
book.format = ''.join(book_data.xpath('.//i/text()'))
|
||||||
book.format = book.format.strip()
|
book.format = book.format.strip()
|
||||||
|
|
||||||
text = ''.join(book_data.xpath('.//a/text()'))
|
text = ''.join(book_data.xpath('.//a/text()'))
|
||||||
if ':' in text:
|
if ':' in text:
|
||||||
book.author, q, text = text.partition(':')
|
book.author, q, text = text.partition(':')
|
||||||
@ -114,7 +114,7 @@ class MobileReadStore(BasicStoreConfig, StorePlugin):
|
|||||||
books.append(book)
|
books.append(book)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Save the book list and it's create time.
|
# Save the book list and it's create time.
|
||||||
if books:
|
if books:
|
||||||
self.config[self.name + '_last_download'] = time.time()
|
self.config[self.name + '_last_download'] = time.time()
|
||||||
@ -126,21 +126,21 @@ class MobileReadStore(BasicStoreConfig, StorePlugin):
|
|||||||
|
|
||||||
|
|
||||||
class BookRef(SearchResult):
|
class BookRef(SearchResult):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
SearchResult.__init__(self)
|
SearchResult.__init__(self)
|
||||||
|
|
||||||
self.format = ''
|
self.format = ''
|
||||||
|
|
||||||
|
|
||||||
class MobeReadStoreDialog(QDialog, Ui_Dialog):
|
class MobeReadStoreDialog(QDialog, Ui_Dialog):
|
||||||
|
|
||||||
def __init__(self, plugin, *args):
|
def __init__(self, plugin, *args):
|
||||||
QDialog.__init__(self, *args)
|
QDialog.__init__(self, *args)
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
|
|
||||||
self.plugin = plugin
|
self.plugin = plugin
|
||||||
|
|
||||||
self.model = BooksModel()
|
self.model = BooksModel()
|
||||||
self.results_view.setModel(self.model)
|
self.results_view.setModel(self.model)
|
||||||
self.results_view.model().set_books(self.plugin.get_book_list())
|
self.results_view.model().set_books(self.plugin.get_book_list())
|
||||||
@ -150,14 +150,14 @@ class MobeReadStoreDialog(QDialog, Ui_Dialog):
|
|||||||
self.search_query.textChanged.connect(self.model.set_filter)
|
self.search_query.textChanged.connect(self.model.set_filter)
|
||||||
self.results_view.model().total_changed.connect(self.total.setText)
|
self.results_view.model().total_changed.connect(self.total.setText)
|
||||||
self.finished.connect(self.dialog_closed)
|
self.finished.connect(self.dialog_closed)
|
||||||
|
|
||||||
self.restore_state()
|
self.restore_state()
|
||||||
|
|
||||||
def open_store(self, index):
|
def open_store(self, index):
|
||||||
result = self.results_view.model().get_book(index)
|
result = self.results_view.model().get_book(index)
|
||||||
if result:
|
if result:
|
||||||
self.plugin.open(self, result.detail_item)
|
self.plugin.open(self, result.detail_item)
|
||||||
|
|
||||||
def restore_state(self):
|
def restore_state(self):
|
||||||
geometry = self.plugin.config['store_mobileread_dialog_geometry']
|
geometry = self.plugin.config['store_mobileread_dialog_geometry']
|
||||||
if geometry:
|
if geometry:
|
||||||
@ -172,7 +172,7 @@ class MobeReadStoreDialog(QDialog, Ui_Dialog):
|
|||||||
else:
|
else:
|
||||||
for i in xrange(self.results_view.model().columnCount()):
|
for i in xrange(self.results_view.model().columnCount()):
|
||||||
self.results_view.resizeColumnToContents(i)
|
self.results_view.resizeColumnToContents(i)
|
||||||
|
|
||||||
self.results_view.model().sort_col = self.plugin.config.get('store_mobileread_dialog_sort_col', 0)
|
self.results_view.model().sort_col = self.plugin.config.get('store_mobileread_dialog_sort_col', 0)
|
||||||
self.results_view.model().sort_order = self.plugin.config.get('store_mobileread_dialog_sort_order', Qt.AscendingOrder)
|
self.results_view.model().sort_order = self.plugin.config.get('store_mobileread_dialog_sort_order', Qt.AscendingOrder)
|
||||||
self.results_view.model().sort(self.results_view.model().sort_col, self.results_view.model().sort_order)
|
self.results_view.model().sort(self.results_view.model().sort_col, self.results_view.model().sort_order)
|
||||||
@ -189,7 +189,7 @@ class MobeReadStoreDialog(QDialog, Ui_Dialog):
|
|||||||
|
|
||||||
|
|
||||||
class BooksModel(QAbstractItemModel):
|
class BooksModel(QAbstractItemModel):
|
||||||
|
|
||||||
total_changed = pyqtSignal(unicode)
|
total_changed = pyqtSignal(unicode)
|
||||||
|
|
||||||
HEADERS = [_('Title'), _('Author(s)'), _('Format')]
|
HEADERS = [_('Title'), _('Author(s)'), _('Format')]
|
||||||
@ -205,7 +205,7 @@ class BooksModel(QAbstractItemModel):
|
|||||||
def set_books(self, books):
|
def set_books(self, books):
|
||||||
self.books = books
|
self.books = books
|
||||||
self.all_books = books
|
self.all_books = books
|
||||||
|
|
||||||
self.sort(self.sort_col, self.sort_order)
|
self.sort(self.sort_col, self.sort_order)
|
||||||
|
|
||||||
def get_book(self, index):
|
def get_book(self, index):
|
||||||
@ -214,11 +214,11 @@ class BooksModel(QAbstractItemModel):
|
|||||||
return self.books[row]
|
return self.books[row]
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def set_filter(self, filter):
|
def set_filter(self, filter):
|
||||||
#self.layoutAboutToBeChanged.emit()
|
#self.layoutAboutToBeChanged.emit()
|
||||||
self.beginResetModel()
|
self.beginResetModel()
|
||||||
|
|
||||||
self.filter = unicode(filter)
|
self.filter = unicode(filter)
|
||||||
self.books = []
|
self.books = []
|
||||||
if self.filter:
|
if self.filter:
|
||||||
@ -241,7 +241,7 @@ class BooksModel(QAbstractItemModel):
|
|||||||
|
|
||||||
self.endResetModel()
|
self.endResetModel()
|
||||||
#self.layoutChanged.emit()
|
#self.layoutChanged.emit()
|
||||||
|
|
||||||
def index(self, row, column, parent=QModelIndex()):
|
def index(self, row, column, parent=QModelIndex()):
|
||||||
return self.createIndex(row, column)
|
return self.createIndex(row, column)
|
||||||
|
|
||||||
@ -255,7 +255,7 @@ class BooksModel(QAbstractItemModel):
|
|||||||
|
|
||||||
def columnCount(self, *args):
|
def columnCount(self, *args):
|
||||||
return len(self.HEADERS)
|
return len(self.HEADERS)
|
||||||
|
|
||||||
def headerData(self, section, orientation, role):
|
def headerData(self, section, orientation, role):
|
||||||
if role != Qt.DisplayRole:
|
if role != Qt.DisplayRole:
|
||||||
return NONE
|
return NONE
|
||||||
@ -295,7 +295,7 @@ class BooksModel(QAbstractItemModel):
|
|||||||
|
|
||||||
if not self.books:
|
if not self.books:
|
||||||
return
|
return
|
||||||
descending = order == Qt.DescendingOrder
|
descending = order == Qt.DescendingOrder
|
||||||
self.books.sort(None,
|
self.books.sort(None,
|
||||||
lambda x: sort_key(unicode(self.data_as_text(x, col))),
|
lambda x: sort_key(unicode(self.data_as_text(x, col))),
|
||||||
descending)
|
descending)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user