From d972dd27b0110f881ca0468ba5799c1696ff2b58 Mon Sep 17 00:00:00 2001 From: GRiker Date: Thu, 13 Sep 2012 13:35:15 -0600 Subject: [PATCH 01/41] Fixed regression referencing output_device --- src/calibre/library/catalogs/epub_mobi.py | 10 +++------- src/calibre/library/catalogs/epub_mobi_builder.py | 3 +++ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/calibre/library/catalogs/epub_mobi.py b/src/calibre/library/catalogs/epub_mobi.py index 0d1e26bce6..6225612cc8 100644 --- a/src/calibre/library/catalogs/epub_mobi.py +++ b/src/calibre/library/catalogs/epub_mobi.py @@ -9,7 +9,6 @@ __docformat__ = 'restructuredtext en' import os, shutil from collections import namedtuple -from copy import deepcopy from calibre import strftime from calibre.customize import CatalogPlugin @@ -329,9 +328,6 @@ class EPUB_MOBI(CatalogPlugin): # Launch the Catalog builder catalog = CatalogBuilder(db, opts, self, report_progress=notification) - # Save the output profile for the plumber - output_profile = deepcopy(catalog.output_profile) - if opts.verbose: log.info(" Begin catalog source generation") @@ -350,8 +346,6 @@ class EPUB_MOBI(CatalogPlugin): recommendations.append(('remove_fake_margins', False, OptionRecommendation.HIGH)) recommendations.append(('comments', '', OptionRecommendation.HIGH)) - recommendations.append(('output_profile', output_profile, - OptionRecommendation.HIGH)) """ >>> Use to debug generated catalog code before pipeline conversion <<< @@ -366,7 +360,9 @@ class EPUB_MOBI(CatalogPlugin): recommendations.append(('debug_pipeline', dp, OptionRecommendation.HIGH)) - if opts.output_profile and opts.output_profile.startswith("kindle"): + if opts.fmt == 'mobi' and opts.output_profile and opts.output_profile.startswith("kindle"): + recommendations.append(('output_profile', opts.output_profile, + OptionRecommendation.HIGH)) recommendations.append(('no_inline_toc', True, OptionRecommendation.HIGH)) recommendations.append(('book_producer',opts.output_profile, diff --git a/src/calibre/library/catalogs/epub_mobi_builder.py b/src/calibre/library/catalogs/epub_mobi_builder.py index d38bbd1b27..0caaad333e 100644 --- a/src/calibre/library/catalogs/epub_mobi_builder.py +++ b/src/calibre/library/catalogs/epub_mobi_builder.py @@ -103,6 +103,9 @@ class CatalogBuilder(object): self.cache_dir = os.path.join(config_dir, 'caches', 'catalog') self.catalog_path = PersistentTemporaryDirectory("_epub_mobi_catalog", prefix='') self.excluded_tags = self.get_excluded_tags() + self.generate_for_kindle_azw3 = True if (_opts.fmt == 'azw3' and + _opts.output_profile and + _opts.output_profile.startswith("kindle")) else False self.generate_for_kindle_mobi = True if (_opts.fmt == 'mobi' and _opts.output_profile and _opts.output_profile.startswith("kindle")) else False From 3151bb134e6b2a4daeae2d4280fbc51770878a1f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 14 Sep 2012 09:36:19 +0530 Subject: [PATCH 02/41] ... --- src/calibre/library/catalogs/epub_mobi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/library/catalogs/epub_mobi.py b/src/calibre/library/catalogs/epub_mobi.py index 6225612cc8..668fb5156f 100644 --- a/src/calibre/library/catalogs/epub_mobi.py +++ b/src/calibre/library/catalogs/epub_mobi.py @@ -7,7 +7,7 @@ __license__ = 'GPL v3' __copyright__ = '2012, Kovid Goyal ' __docformat__ = 'restructuredtext en' -import os, shutil +import os from collections import namedtuple from calibre import strftime From 55a3704021a38a5e5eab86ef3c6e195c40311986 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 14 Sep 2012 09:39:50 +0530 Subject: [PATCH 03/41] version 0.8.69 --- Changelog.yaml | 44 ++++++++++++++++++++++++++++++++++++++++ src/calibre/constants.py | 2 +- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/Changelog.yaml b/Changelog.yaml index b0a9bd68d4..25d8b68cc5 100644 --- a/Changelog.yaml +++ b/Changelog.yaml @@ -19,6 +19,50 @@ # new recipes: # - title: +- version: 0.8.69 + date: 2012-09-14 + + new features: + - title: "E-book viewer: Add a button to the toolbar to switch themes easily" + tickets: [1047992] + + - title: "When downloading metadata for many books, if some of them fail, add an option to the downloaded message to show the failed books in the main book list, so that they can be individually processed easily" + + - title: "Remember last used window size of the conversion dialogs." + tickets: [1049265] + + - title: "Kindle driver: Turn on sending of azw3 files to kindles by default, since the KK now has azw3 support" + + - title: "Conversion: Add support for CSS pseudo classes :hover, :link, :visited, :first-line, :focus, :active, :first-letter" + + - title: "Wireless device driver: Make the default save template not use folders" + + bug fixes: + - title: "Fix a regression in th previous release that broke sending of books to the second SD card in SONY readers" + tickets: [1047992] + + - title: "Fix a memory leak when scanning for devices in windows" + + - title: "Ebook-viewer: When displaying mathematics, reflow equations that dont fit on a single line" + + - title: "Catalogs: Do not mark the AZW3 catalog as a periodical, as most Kindle devices cannot handle AZW3 periodicals" + + - title: "Content server: When using a custom IP address to listen on via Preferences->Tweaks advertise that IP address via BonJour." + + - title: "Fix ebook catalog generation on linux systems where the encoding is not UTF-8." + tickets: [1048404] + + improved recipes: + - De Volksrant + - Metro UK + - Countryfile + - Die Zeit (subscription) + - Birmingham post + + new recipes: + - title: History Today + author: Rick Shang + - version: 0.8.68 date: 2012-09-07 diff --git a/src/calibre/constants.py b/src/calibre/constants.py index d70c186502..391a64027f 100644 --- a/src/calibre/constants.py +++ b/src/calibre/constants.py @@ -4,7 +4,7 @@ __license__ = 'GPL v3' __copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net' __docformat__ = 'restructuredtext en' __appname__ = u'calibre' -numeric_version = (0, 8, 68) +numeric_version = (0, 8, 69) __version__ = u'.'.join(map(unicode, numeric_version)) __author__ = u"Kovid Goyal " From fc8a6d1fb73d87c457c5faa79f263f69ca442bcd Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 14 Sep 2012 10:16:17 +0530 Subject: [PATCH 04/41] IGN:Tag release --- src/calibre/translations/calibre.pot | 809 +++++++++++++++------------ 1 file changed, 443 insertions(+), 366 deletions(-) diff --git a/src/calibre/translations/calibre.pot b/src/calibre/translations/calibre.pot index c2f5e1b38c..c72755c50a 100644 --- a/src/calibre/translations/calibre.pot +++ b/src/calibre/translations/calibre.pot @@ -4,9 +4,9 @@ # msgid "" msgstr "" -"Project-Id-Version: calibre 0.8.68\n" -"POT-Creation-Date: 2012-09-08 17:09+IST\n" -"PO-Revision-Date: 2012-09-08 17:09+IST\n" +"Project-Id-Version: calibre 0.8.69\n" +"POT-Creation-Date: 2012-09-14 09:40+IST\n" +"PO-Revision-Date: 2012-09-14 09:40+IST\n" "Last-Translator: Automatically generated\n" "Language-Team: LANGUAGE\n" "MIME-Version: 1.0\n" @@ -24,8 +24,8 @@ msgstr "" #: /home/kovid/work/calibre/src/calibre/db/cache.py:106 #: /home/kovid/work/calibre/src/calibre/db/cache.py:109 #: /home/kovid/work/calibre/src/calibre/db/cache.py:120 -#: /home/kovid/work/calibre/src/calibre/devices/android/driver.py:370 -#: /home/kovid/work/calibre/src/calibre/devices/android/driver.py:371 +#: /home/kovid/work/calibre/src/calibre/devices/android/driver.py:373 +#: /home/kovid/work/calibre/src/calibre/devices/android/driver.py:374 #: /home/kovid/work/calibre/src/calibre/devices/hanvon/driver.py:100 #: /home/kovid/work/calibre/src/calibre/devices/hanvon/driver.py:101 #: /home/kovid/work/calibre/src/calibre/devices/jetbook/driver.py:74 @@ -33,8 +33,8 @@ msgstr "" #: /home/kovid/work/calibre/src/calibre/devices/kobo/books.py:25 #: /home/kovid/work/calibre/src/calibre/devices/kobo/driver.py:656 #: /home/kovid/work/calibre/src/calibre/devices/mtp/books.py:44 -#: /home/kovid/work/calibre/src/calibre/devices/mtp/unix/driver.py:190 -#: /home/kovid/work/calibre/src/calibre/devices/mtp/windows/driver.py:206 +#: /home/kovid/work/calibre/src/calibre/devices/mtp/unix/driver.py:204 +#: /home/kovid/work/calibre/src/calibre/devices/mtp/windows/driver.py:211 #: /home/kovid/work/calibre/src/calibre/devices/nook/driver.py:70 #: /home/kovid/work/calibre/src/calibre/devices/nook/driver.py:71 #: /home/kovid/work/calibre/src/calibre/devices/prs505/sony_cache.py:661 @@ -134,17 +134,17 @@ msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:439 #: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:447 #: /home/kovid/work/calibre/src/calibre/gui2/actions/add.py:166 -#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:397 -#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:400 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:411 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:414 #: /home/kovid/work/calibre/src/calibre/gui2/add.py:159 #: /home/kovid/work/calibre/src/calibre/gui2/add.py:166 -#: /home/kovid/work/calibre/src/calibre/gui2/book_details.py:672 +#: /home/kovid/work/calibre/src/calibre/gui2/book_details.py:680 #: /home/kovid/work/calibre/src/calibre/gui2/convert/__init__.py:41 #: /home/kovid/work/calibre/src/calibre/gui2/convert/metadata.py:124 #: /home/kovid/work/calibre/src/calibre/gui2/convert/metadata.py:143 #: /home/kovid/work/calibre/src/calibre/gui2/convert/metadata.py:145 -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1367 -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1370 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1381 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1384 #: /home/kovid/work/calibre/src/calibre/gui2/dialogs/add_empty_book.py:55 #: /home/kovid/work/calibre/src/calibre/gui2/dialogs/add_empty_book.py:60 #: /home/kovid/work/calibre/src/calibre/gui2/dialogs/book_info.py:128 @@ -204,7 +204,7 @@ msgstr "" #: /home/kovid/work/calibre/src/calibre/customize/__init__.py:156 #: /home/kovid/work/calibre/src/calibre/gui2/actions/preferences.py:54 #: /home/kovid/work/calibre/src/calibre/gui2/actions/preferences.py:59 -#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:165 +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:355 msgid "Cannot configure" msgstr "" @@ -234,7 +234,7 @@ msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/preferences/main.py:197 #: /home/kovid/work/calibre/src/calibre/gui2/preferences/main.py:288 #: /home/kovid/work/calibre/src/calibre/gui2/preferences/main.py:311 -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:215 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:221 msgid "Preferences" msgstr "" @@ -904,19 +904,19 @@ msgstr "" msgid "Communicate with Android phones." msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/android/driver.py:194 +#: /home/kovid/work/calibre/src/calibre/devices/android/driver.py:195 msgid "Comma separated list of directories to send e-books to on the device's main memory. The first one that exists will be used" msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/android/driver.py:197 +#: /home/kovid/work/calibre/src/calibre/devices/android/driver.py:198 msgid "Comma separated list of directories to send e-books to on the device's storage cards. The first one that exists will be used" msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/android/driver.py:310 +#: /home/kovid/work/calibre/src/calibre/devices/android/driver.py:313 msgid "Communicate with S60 phones." msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/android/driver.py:329 +#: /home/kovid/work/calibre/src/calibre/devices/android/driver.py:332 msgid "Communicate with WebOS tablets." msgstr "" @@ -1022,9 +1022,9 @@ msgstr "" #: /home/kovid/work/calibre/src/calibre/devices/prs505/sony_cache.py:471 #: /home/kovid/work/calibre/src/calibre/devices/prst1/driver.py:773 #: /home/kovid/work/calibre/src/calibre/devices/prst1/driver.py:792 -#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:253 -#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:259 -#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:293 +#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:256 +#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:262 +#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:296 #: /home/kovid/work/calibre/src/calibre/devices/utils.py:80 #: /home/kovid/work/calibre/src/calibre/devices/utils.py:84 #: /home/kovid/work/calibre/src/calibre/devices/utils.py:116 @@ -1098,9 +1098,9 @@ msgstr "" #: /home/kovid/work/calibre/src/calibre/devices/bambook/driver.py:264 #: /home/kovid/work/calibre/src/calibre/devices/bambook/driver.py:268 #: /home/kovid/work/calibre/src/calibre/devices/bambook/driver.py:324 -#: /home/kovid/work/calibre/src/calibre/devices/mtp/driver.py:322 -#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:897 -#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:899 +#: /home/kovid/work/calibre/src/calibre/devices/mtp/driver.py:340 +#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:930 +#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:932 #: /home/kovid/work/calibre/src/calibre/devices/usbms/driver.py:277 #: /home/kovid/work/calibre/src/calibre/devices/usbms/driver.py:279 msgid "Transferring books to device..." @@ -1110,9 +1110,9 @@ msgstr "" #: /home/kovid/work/calibre/src/calibre/devices/bambook/driver.py:344 #: /home/kovid/work/calibre/src/calibre/devices/kobo/driver.py:480 #: /home/kovid/work/calibre/src/calibre/devices/kobo/driver.py:515 -#: /home/kovid/work/calibre/src/calibre/devices/mtp/driver.py:357 -#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:910 -#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:921 +#: /home/kovid/work/calibre/src/calibre/devices/mtp/driver.py:377 +#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:943 +#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:954 #: /home/kovid/work/calibre/src/calibre/devices/usbms/driver.py:301 #: /home/kovid/work/calibre/src/calibre/devices/usbms/driver.py:332 msgid "Adding books to device metadata listing..." @@ -1134,8 +1134,8 @@ msgstr "" #: /home/kovid/work/calibre/src/calibre/devices/bambook/driver.py:374 #: /home/kovid/work/calibre/src/calibre/devices/kobo/driver.py:468 #: /home/kovid/work/calibre/src/calibre/devices/kobo/driver.py:475 -#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:941 -#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:947 +#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:974 +#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:980 #: /home/kovid/work/calibre/src/calibre/devices/usbms/driver.py:366 #: /home/kovid/work/calibre/src/calibre/devices/usbms/driver.py:371 msgid "Removing books from device metadata listing..." @@ -1567,75 +1567,75 @@ msgstr "" msgid "Communicate with MTP devices" msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/mtp/driver.py:105 -#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:745 +#: /home/kovid/work/calibre/src/calibre/devices/mtp/driver.py:124 +#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:758 #: /home/kovid/work/calibre/src/calibre/devices/usbms/driver.py:95 msgid "Get device information..." msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/mtp/driver.py:143 +#: /home/kovid/work/calibre/src/calibre/devices/mtp/driver.py:158 msgid "Reading metadata from device" msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/mtp/driver.py:176 +#: /home/kovid/work/calibre/src/calibre/devices/mtp/driver.py:191 #, python-format msgid "Reading metadata from %s" msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/mtp/driver.py:195 +#: /home/kovid/work/calibre/src/calibre/devices/mtp/driver.py:210 msgid "Updating metadata cache on device" msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/mtp/driver.py:197 +#: /home/kovid/work/calibre/src/calibre/devices/mtp/driver.py:212 msgid "Finished reading metadata from device" msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/mtp/driver.py:346 +#: /home/kovid/work/calibre/src/calibre/devices/mtp/driver.py:366 #, python-format msgid "Transferred %s to device" msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/mtp/driver.py:348 +#: /home/kovid/work/calibre/src/calibre/devices/mtp/driver.py:368 msgid "Transfer to device finished..." msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/mtp/driver.py:369 +#: /home/kovid/work/calibre/src/calibre/devices/mtp/driver.py:389 #, python-format msgid "Added %s" msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/mtp/driver.py:371 +#: /home/kovid/work/calibre/src/calibre/devices/mtp/driver.py:391 msgid "Adding complete" msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/mtp/driver.py:387 +#: /home/kovid/work/calibre/src/calibre/devices/mtp/driver.py:407 msgid "Deleting books from device..." msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/mtp/driver.py:393 +#: /home/kovid/work/calibre/src/calibre/devices/mtp/driver.py:413 #, python-format msgid "Deleted %s" msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/mtp/driver.py:394 +#: /home/kovid/work/calibre/src/calibre/devices/mtp/driver.py:414 msgid "All books deleted" msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/mtp/driver.py:397 +#: /home/kovid/work/calibre/src/calibre/devices/mtp/driver.py:417 msgid "Removing books from metadata" msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/mtp/driver.py:409 +#: /home/kovid/work/calibre/src/calibre/devices/mtp/driver.py:429 #, python-format msgid "Removed %s" msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/mtp/driver.py:411 +#: /home/kovid/work/calibre/src/calibre/devices/mtp/driver.py:431 msgid "All books removed" msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/mtp/unix/driver.py:178 -#: /home/kovid/work/calibre/src/calibre/devices/mtp/windows/driver.py:267 +#: /home/kovid/work/calibre/src/calibre/devices/mtp/unix/driver.py:190 +#: /home/kovid/work/calibre/src/calibre/devices/mtp/windows/driver.py:280 msgid "Unknown MTP device" msgstr "" @@ -1680,12 +1680,12 @@ msgid "Comments have been removed as the SONY reader chokes on them" msgstr "" #: /home/kovid/work/calibre/src/calibre/devices/prs505/driver.py:66 -#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:129 +#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:132 msgid "All by title" msgstr "" #: /home/kovid/work/calibre/src/calibre/devices/prs505/driver.py:67 -#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:130 +#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:133 msgid "All by author" msgstr "" @@ -1763,99 +1763,99 @@ msgstr "" msgid "Set this option if you want the author on the Sony to appear the same way the T1 sets it. This means it will only show the first author for books with multiple authors. Leave this disabled if you use Metadata Plugboards." msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:58 +#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:59 msgid "SmartDevice" msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:60 +#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:61 msgid "Communicate with Smart Device apps" msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:131 +#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:134 msgid "All by something" msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:134 +#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:137 msgid "Enable connections at startup" msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:135 +#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:138 msgid "Check this box to allow connections when calibre starts" msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:137 +#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:140 msgid "Security password" msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:138 +#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:141 msgid "Enter a password that the device app must use to connect to calibre" msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:140 +#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:143 msgid "Use fixed network port" msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:141 +#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:144 msgid "If checked, use the port number in the \"Port\" box, otherwise the driver will pick a random port" msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:143 +#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:146 msgid "Port number: " msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:144 +#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:147 msgid "Enter the port number the driver is to use if the \"fixed port\" box is checked" msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:145 +#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:148 msgid "Print extra debug information" msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:146 +#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:149 msgid "Check this box if requested when reporting problems" msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:148 +#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:151 msgid "Comma separated list of metadata fields to turn into collections on the device." msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:150 +#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:153 msgid "Possibilities include: series, tags, authors, etc" msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:158 +#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:161 msgid "Enable the no-activity timeout" msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:159 +#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:162 #, python-format msgid "If this box is checked, calibre will automatically disconnect if a connected device does nothing for %d minutes. Unchecking this box disables this timeout, so calibre will never automatically disconnect." msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:163 +#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:166 msgid "Use this IP address" msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:164 +#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:167 msgid "Use this option if you want to force the driver to listen on a particular IP address. The driver will listen only on the entered address, and this address will be the one advertized over mDNS (bonjour)." msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:628 +#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:641 #, python-format msgid "Too many connection attempts from %s" msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:1027 +#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:1068 #, python-format msgid "Invalid port in options: %s" msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:1035 +#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:1076 #, python-format msgid "Failed to connect to port %d. Try a different value." msgstr "" -#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:1047 +#: /home/kovid/work/calibre/src/calibre/devices/smart_device_app/driver.py:1088 msgid "Failed to allocate a random port" msgstr "" @@ -3008,8 +3008,9 @@ msgstr "" msgid "Running transforms on ebook..." msgstr "" -#: /home/kovid/work/calibre/src/calibre/ebooks/conversion/plumber.py:1123 -msgid "Creating" +#: /home/kovid/work/calibre/src/calibre/ebooks/conversion/plumber.py:1125 +#, python-format +msgid "Running %s plugin" msgstr "" #: /home/kovid/work/calibre/src/calibre/ebooks/epub/fix/__init__.py:20 @@ -3352,8 +3353,8 @@ msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/library/models.py:67 #: /home/kovid/work/calibre/src/calibre/gui2/preferences/create_custom_column.py:70 #: /home/kovid/work/calibre/src/calibre/gui2/preferences/metadata_sources.py:163 -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:292 -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:2142 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:294 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:2144 #: /home/kovid/work/calibre/src/calibre/library/field_metadata.py:140 msgid "Series" msgid_plural "Series" @@ -3612,7 +3613,7 @@ msgstr "" #: /home/kovid/work/calibre/src/calibre/ebooks/mobi/writer8/toc.py:15 #: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:1281 #: /home/kovid/work/calibre/src/calibre/ebooks/oeb/transforms/htmltoc.py:15 -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:208 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:214 #: /home/kovid/work/calibre/src/calibre/gui2/viewer/toc.py:217 msgid "Table of Contents" msgstr "" @@ -3890,7 +3891,7 @@ msgstr "" msgid "Restart calibre now" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:559 +#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:560 msgid "Choose Files" msgstr "" @@ -4001,9 +4002,9 @@ msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/actions/convert.py:107 #: /home/kovid/work/calibre/src/calibre/gui2/actions/copy_to_library.py:175 #: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:75 -#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:178 -#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:242 -#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:279 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:192 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:256 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:293 #: /home/kovid/work/calibre/src/calibre/gui2/actions/save_to_disk.py:82 msgid "No books selected" msgstr "" @@ -4122,7 +4123,7 @@ msgid "Merging user annotations into database" msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/actions/annotate.py:63 -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:745 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:758 msgid "Fetch annotations (experimental)" msgstr "" @@ -4367,7 +4368,7 @@ msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/actions/choose_library.py:403 #: /home/kovid/work/calibre/src/calibre/gui2/actions/copy_to_library.py:197 -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:934 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:947 #: /home/kovid/work/calibre/src/calibre/gui2/dialogs/metadata_bulk.py:1004 #: /home/kovid/work/calibre/src/calibre/gui2/dialogs/restore_library.py:114 #: /home/kovid/work/calibre/src/calibre/gui2/dialogs/restore_library.py:128 @@ -4600,14 +4601,14 @@ msgid "Main memory" msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/actions/delete.py:239 -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:670 -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:679 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:683 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:692 msgid "Storage Card A" msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/actions/delete.py:240 -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:672 -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:681 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:685 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:694 msgid "Storage Card B" msgstr "" @@ -4636,87 +4637,87 @@ msgstr "" msgid "The selected books will be permanently deleted from your device. Are you sure?" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:31 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:32 msgid "Start wireless device connection" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:32 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:33 msgid "Stop wireless device connection" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:36 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:37 msgid "Connect to folder" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:41 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:42 msgid "Connect to iTunes" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:47 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:48 msgid "Connect to Bambook" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:61 -#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:88 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:62 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:89 msgid "Start Content Server" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:83 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:84 msgid "Start/stop content server" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:90 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:93 msgid "Stop Content Server" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:104 -#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:123 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:107 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:126 msgid "Email to" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:108 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:111 msgid "Email to and delete from library" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:117 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:120 msgid "(delete from library)" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:132 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:135 msgid "Setup email based sharing of books" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:150 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:153 msgid "D" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:150 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:153 msgid "Send to device" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:168 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:171 msgid "Connect/share" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:206 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:209 #: /home/kovid/work/calibre/src/calibre/gui2/preferences/server.py:85 msgid "Stopping" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:207 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:210 #: /home/kovid/work/calibre/src/calibre/gui2/preferences/server.py:86 msgid "Stopping server, this could take upto a minute, please wait..." msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:226 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:229 msgid "Disable autostart" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:227 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:230 msgid "Do you want wireless device connections to be started automatically when calibre starts?" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:250 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/device.py:253 msgid "Many IP addresses. See Start/Stop dialog." msgstr "" @@ -4797,70 +4798,74 @@ msgstr "" msgid "Finished downloading metadata for %d book(s). Proceed with updating the metadata in your library?" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:114 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:115 #, python-format msgid "Could not download metadata and/or covers for %d of the books. Click \"Show details\" to see which books." msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:120 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:117 +msgid "Show the &failed books in the main book list after updating metadata" +msgstr "" + +#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:123 msgid "Download complete" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:120 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:123 #: /home/kovid/work/calibre/src/calibre/gui2/metadata/single_download.py:887 msgid "Download log" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:147 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:151 msgid "Some books changed" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:148 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:152 msgid "The metadata for some books in your library has changed since you started the download. If you proceed, some of those changes may be overwritten. Click \"Show details\" to see the list of changed books. Do you want to proceed?" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:177 -#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:241 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:191 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:255 msgid "Cannot edit metadata" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:278 -#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:281 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:292 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:295 msgid "Cannot merge books" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:282 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:296 msgid "At least two books must be selected for merging" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:285 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:299 msgid "You are about to merge more than 5 books. Are you sure you want to proceed?" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:294 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:308 #, python-format msgid "Book formats and metadata from the selected books will be added to the first selected book (%s). ISBN will not be merged.

The second and subsequently selected books will not be deleted or changed.

Please confirm you want to proceed." msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:306 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:320 #, python-format msgid "Book formats from the selected books will be merged into the first selected book (%s). Metadata in the first selected book will not be changed. Author, Title, ISBN and all other metadata will not be merged.

After merger the second and subsequently selected books, with any metadata they have will be deleted.

All book formats of the first selected book will be kept and any duplicate formats in the second and subsequently selected books will be permanently deleted from your calibre library.

Are you sure you want to proceed?" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:322 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:336 #, python-format msgid "Book formats and metadata from the selected books will be merged into the first selected book (%s). ISBN will not be merged.

After merger the second and subsequently selected books will be deleted.

All book formats of the first selected book will be kept and any duplicate formats in the second and subsequently selected books will be permanently deleted from your calibre library.

Are you sure you want to proceed?" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:497 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:511 msgid "Applying changed metadata" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:587 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:601 msgid "Some failures" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:588 +#: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:602 msgid "Failed to apply updated metadata for some books in your library. Click \"Show Details\" to see details." msgstr "" @@ -4895,7 +4900,7 @@ msgid "Move to next match" msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/actions/next_match.py:13 -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:213 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:219 msgid "F3" msgstr "" @@ -4921,7 +4926,7 @@ msgid "Shift+N" msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/actions/next_match.py:27 -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:222 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:228 msgid "Shift+F3" msgstr "" @@ -5383,7 +5388,7 @@ msgid "The specified directory could not be processed." msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/add.py:274 -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1088 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1102 msgid "No books" msgstr "" @@ -5562,7 +5567,7 @@ msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/store/search/search_ui.py:143 #: /home/kovid/work/calibre/src/calibre/gui2/store/search/search_ui.py:149 #: /home/kovid/work/calibre/src/calibre/gui2/store/stores/mobileread/store_dialog_ui.py:75 -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:200 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:206 msgid "..." msgstr "" @@ -5589,60 +5594,60 @@ msgstr "" msgid "Donate" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/book_details.py:156 +#: /home/kovid/work/calibre/src/calibre/gui2/book_details.py:155 msgid "Click to open" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/book_details.py:171 +#: /home/kovid/work/calibre/src/calibre/gui2/book_details.py:179 msgid "Ids" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/book_details.py:209 +#: /home/kovid/work/calibre/src/calibre/gui2/book_details.py:217 #, python-format msgid "Book %(sidx)s of %(series)s" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/book_details.py:224 +#: /home/kovid/work/calibre/src/calibre/gui2/book_details.py:232 #: /home/kovid/work/calibre/src/calibre/gui2/library/models.py:1071 msgid "Collections" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/book_details.py:328 +#: /home/kovid/work/calibre/src/calibre/gui2/book_details.py:336 #: /home/kovid/work/calibre/src/calibre/gui2/widgets.py:255 msgid "Paste Cover" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/book_details.py:329 +#: /home/kovid/work/calibre/src/calibre/gui2/book_details.py:337 #: /home/kovid/work/calibre/src/calibre/gui2/widgets.py:256 msgid "Copy Cover" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/book_details.py:330 +#: /home/kovid/work/calibre/src/calibre/gui2/book_details.py:338 msgid "Remove Cover" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/book_details.py:373 +#: /home/kovid/work/calibre/src/calibre/gui2/book_details.py:381 msgid "Double-click to open Book Details window" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/book_details.py:374 +#: /home/kovid/work/calibre/src/calibre/gui2/book_details.py:382 #: /home/kovid/work/calibre/src/calibre/gui2/dialogs/delete_matching_from_device.py:77 #: /home/kovid/work/calibre/src/calibre/library/field_metadata.py:295 msgid "Path" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/book_details.py:375 +#: /home/kovid/work/calibre/src/calibre/gui2/book_details.py:383 #: /home/kovid/work/calibre/src/calibre/gui2/dialogs/book_info.py:109 #, python-format msgid "Cover size: %(width)d x %(height)d" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/book_details.py:461 +#: /home/kovid/work/calibre/src/calibre/gui2/book_details.py:469 #, python-format msgid "Delete the %s format" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/book_details.py:462 +#: /home/kovid/work/calibre/src/calibre/gui2/book_details.py:470 #, python-format msgid "Save the %s format to disk" msgstr "" @@ -5710,7 +5715,7 @@ msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/convert/look_and_feel_ui.py:188 #: /home/kovid/work/calibre/src/calibre/gui2/convert/lrf_output_ui.py:120 #: /home/kovid/work/calibre/src/calibre/gui2/convert/metadata_ui.py:158 -#: /home/kovid/work/calibre/src/calibre/gui2/convert/mobi_output_ui.py:75 +#: /home/kovid/work/calibre/src/calibre/gui2/convert/mobi_output_ui.py:79 #: /home/kovid/work/calibre/src/calibre/gui2/convert/page_setup_ui.py:124 #: /home/kovid/work/calibre/src/calibre/gui2/convert/pdb_input_ui.py:36 #: /home/kovid/work/calibre/src/calibre/gui2/convert/pdb_output_ui.py:47 @@ -5817,59 +5822,59 @@ msgid "Wishlist item" msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:133 -#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:769 +#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:795 msgid "any date" msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:133 -#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:767 +#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:793 msgid "any value" msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:135 -#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:765 -#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:767 -#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:769 +#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:791 +#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:793 +#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:795 msgid "unspecified" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:159 +#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:185 msgid "No genres will be excluded" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:168 +#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:194 #, python-format msgid "regex error: %s" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:177 +#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:203 msgid "All genres will be excluded" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:613 +#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:639 #, python-format msgid "Are you sure you want to delete '%s'?" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:615 +#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:641 #, python-format msgid "Are you sure you want to delete rules #%(first)d-%(last)d?" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:616 +#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:642 msgid "Delete Rule" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:765 +#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:791 msgid "False" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:765 +#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:791 msgid "True" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:790 -#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:881 +#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:816 +#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:907 #: /home/kovid/work/calibre/src/calibre/gui2/dialogs/check_library.py:342 #: /home/kovid/work/calibre/src/calibre/gui2/store/config/chooser/models.py:21 #: /home/kovid/work/calibre/src/calibre/gui2/viewer/bookmarkmanager.py:90 @@ -5877,17 +5882,17 @@ msgstr "" msgid "Name" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:791 -#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:883 +#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:817 +#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:909 msgid "Field" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:792 -#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:884 +#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:818 +#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:910 msgid "Value" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:882 +#: /home/kovid/work/calibre/src/calibre/gui2/catalog/catalog_epub_mobi.py:908 msgid "Prefix" msgstr "" @@ -6182,7 +6187,7 @@ msgid "Choose foreground color" msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/comments_editor.py:189 -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/config.py:220 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/config.py:223 msgid "Choose background color" msgstr "" @@ -6211,32 +6216,32 @@ msgid "AZW3 Output" msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/convert/azw3_output_ui.py:53 -#: /home/kovid/work/calibre/src/calibre/gui2/convert/mobi_output_ui.py:80 +#: /home/kovid/work/calibre/src/calibre/gui2/convert/mobi_output_ui.py:84 msgid "Use author &sort for author" msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/convert/azw3_output_ui.py:54 -#: /home/kovid/work/calibre/src/calibre/gui2/convert/mobi_output_ui.py:77 +#: /home/kovid/work/calibre/src/calibre/gui2/convert/mobi_output_ui.py:81 msgid "&Title for Table of Contents:" msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/convert/azw3_output_ui.py:55 -#: /home/kovid/work/calibre/src/calibre/gui2/convert/mobi_output_ui.py:86 +#: /home/kovid/work/calibre/src/calibre/gui2/convert/mobi_output_ui.py:90 msgid "Enable sharing of book content via Facebook, etc. WARNING: Disables last read syncing" msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/convert/azw3_output_ui.py:56 -#: /home/kovid/work/calibre/src/calibre/gui2/convert/mobi_output_ui.py:76 +#: /home/kovid/work/calibre/src/calibre/gui2/convert/mobi_output_ui.py:80 msgid "Do not add Table of Contents to book" msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/convert/azw3_output_ui.py:57 -#: /home/kovid/work/calibre/src/calibre/gui2/convert/mobi_output_ui.py:78 +#: /home/kovid/work/calibre/src/calibre/gui2/convert/mobi_output_ui.py:82 msgid "Put generated Table of Contents at &start of book instead of end" msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/convert/azw3_output_ui.py:58 -#: /home/kovid/work/calibre/src/calibre/gui2/convert/mobi_output_ui.py:82 +#: /home/kovid/work/calibre/src/calibre/gui2/convert/mobi_output_ui.py:86 msgid "Disable compression of the file contents" msgstr "" @@ -6248,7 +6253,7 @@ msgstr "" msgid "None of the selected books have saved conversion settings." msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/convert/bulk.py:81 +#: /home/kovid/work/calibre/src/calibre/gui2/convert/bulk.py:84 msgid "Bulk Convert" msgstr "" @@ -6778,7 +6783,7 @@ msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/convert/metadata.py:47 #: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:98 -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:209 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:215 msgid "Metadata" msgstr "" @@ -6904,26 +6909,30 @@ msgstr "" msgid "MOBI Output" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/convert/mobi_output_ui.py:79 +#: /home/kovid/work/calibre/src/calibre/gui2/convert/mobi_output_ui.py:83 msgid "Ignore &margins" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/convert/mobi_output_ui.py:81 +#: /home/kovid/work/calibre/src/calibre/gui2/convert/mobi_output_ui.py:85 msgid "Do not convert all images to &JPEG (may result in images not working in older viewers)" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/convert/mobi_output_ui.py:83 +#: /home/kovid/work/calibre/src/calibre/gui2/convert/mobi_output_ui.py:87 msgid "Kindle options" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/convert/mobi_output_ui.py:84 +#: /home/kovid/work/calibre/src/calibre/gui2/convert/mobi_output_ui.py:88 msgid "MOBI file &type:" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/convert/mobi_output_ui.py:85 +#: /home/kovid/work/calibre/src/calibre/gui2/convert/mobi_output_ui.py:89 msgid "Personal Doc tag:" msgstr "" +#: /home/kovid/work/calibre/src/calibre/gui2/convert/mobi_output_ui.py:91 +msgid "WARNING: Various Kindle devices have trouble displaying the new or both MOBI filetypes. If you wish to use the new format on your device, convert to AZW3 instead of MOBI." +msgstr "" + #: /home/kovid/work/calibre/src/calibre/gui2/convert/page_setup.py:35 msgid "Page Setup" msgstr "" @@ -7289,7 +7298,7 @@ msgstr "" msgid "

Search and replace uses regular expressions. See the regular expressions tutorial to get started with regular expressions. Also clicking the wizard button below will allow you to test your regular expression against the current input document. When you are happy with an expression, click the Add button to add it to the list of expressions." msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/convert/single.py:181 +#: /home/kovid/work/calibre/src/calibre/gui2/convert/single.py:184 msgid "Convert" msgstr "" @@ -7707,222 +7716,222 @@ msgstr "" msgid "tags to remove" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:51 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:52 #: /home/kovid/work/calibre/src/calibre/utils/ipc/job.py:148 msgid "No details available." msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:203 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:204 msgid "Device no longer connected." msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:414 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:418 #: /home/kovid/work/calibre/src/calibre/gui2/preferences/device_debug.py:27 msgid "Debug device detection" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:430 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:434 msgid "Get device information" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:445 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:458 msgid "Get list of books on device" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:452 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:465 msgid "Prepare files for transfer from device" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:463 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:476 msgid "Get annotations from device" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:475 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:488 msgid "Send metadata to device" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:480 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:493 msgid "Send collections to device" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:530 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:543 #, python-format msgid "Upload %d books to device" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:546 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:559 msgid "Delete books from device" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:564 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:577 msgid "Download books from device" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:574 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:587 msgid "View book on device" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:653 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:666 msgid "Set default send to device action" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:659 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:672 msgid "Send to main memory" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:661 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:674 msgid "Send to storage card A" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:663 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:676 msgid "Send to storage card B" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:668 -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:677 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:681 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:690 msgid "Main Memory" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:689 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:702 msgid "Send specific format to" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:690 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:703 msgid "Send and delete from library" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:733 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:746 msgid "Eject device" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:814 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:827 #: /home/kovid/work/calibre/src/calibre/gui2/preferences/misc.py:71 #: /home/kovid/work/calibre/src/calibre/gui2/preferences/plugins.py:332 #: /home/kovid/work/calibre/src/calibre/utils/ipc/job.py:58 msgid "Error" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:815 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:828 msgid "Error communicating with device" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:844 -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1417 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:857 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1431 #: /home/kovid/work/calibre/src/calibre/gui2/email.py:260 msgid "No suitable formats" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:860 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:873 msgid "Select folder to open as device" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:878 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:891 msgid "Running jobs" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:879 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:892 msgid "Cannot configure the device while there are running device jobs." msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:884 -#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:168 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:897 +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:358 #, python-format msgid "Configure %s" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:899 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:912 #, python-format msgid "Restart calibre for the changes to %s to be applied." msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:940 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:953 msgid "Error talking to device" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:941 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:954 msgid "There was a temporary error talking to the device. Please unplug and reconnect the device or reboot." msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:985 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:998 msgid "Device: " msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:987 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1000 msgid " detected." msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1089 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1103 msgid "selected to send" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1096 -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1126 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1110 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1140 msgid "No device" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1097 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1111 msgid "No device connected" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1113 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1127 #, python-format msgid "%(num)i of %(total)i Books" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1117 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1131 #, python-format msgid "0 of %i Books" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1118 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1132 msgid "Choose format to send to device" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1127 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1141 msgid "Cannot send: No device is connected" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1130 -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1134 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1144 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1148 msgid "No card" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1131 -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1135 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1145 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1149 msgid "Cannot send: Device has no storage card" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1196 -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1279 -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1411 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1210 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1293 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1425 msgid "Auto convert the following books before uploading to the device?" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1225 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1239 msgid "Sending catalogs to device." msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1324 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1338 msgid "Sending news to device." msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1378 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1392 msgid "Sending books to device." msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1418 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1432 msgid "Could not upload the following books to the device, as no suitable formats were found. Convert the book(s) to a format supported by your device first." msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1491 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1505 msgid "No space on device" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1492 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1506 msgid "

Cannot upload books to device there is no more free space available " msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1497 +#: /home/kovid/work/calibre/src/calibre/gui2/device.py:1511 msgid "Incorrect destination" msgstr "" @@ -7935,7 +7944,7 @@ msgid "You have enabled the {0} formats for your {1}. The {1} may not sup msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/configwidget.py:155 -#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:109 +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:112 #: /home/kovid/work/calibre/src/calibre/gui2/library/delegates.py:449 #: /home/kovid/work/calibre/src/calibre/gui2/preferences/plugboard.py:279 #: /home/kovid/work/calibre/src/calibre/gui2/preferences/save_template.py:70 @@ -7943,7 +7952,7 @@ msgid "Invalid template" msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/configwidget.py:156 -#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:110 +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:113 #: /home/kovid/work/calibre/src/calibre/gui2/library/delegates.py:450 #: /home/kovid/work/calibre/src/calibre/gui2/preferences/plugboard.py:280 #: /home/kovid/work/calibre/src/calibre/gui2/preferences/save_template.py:71 @@ -7971,55 +7980,115 @@ msgstr "" msgid "Save &template:" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:53 +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:56 msgid "No formats selected" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:54 +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:57 msgid "You must choose at least one format to send to the device" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:82 +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:85 msgid "" "Save &template to control the filename and\n" " location of files sent to the device:" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:88 -msgid "Template editor" +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:91 +msgid "&Template editor" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:98 +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:101 #: /home/kovid/work/calibre/src/calibre/gui2/dialogs/template_line_editor.py:41 #: /home/kovid/work/calibre/src/calibre/gui2/library/delegates.py:436 #: /home/kovid/work/calibre/src/calibre/gui2/preferences/save_template.py:48 msgid "Edit template" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:125 +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:128 msgid "" "A list of &folders on the device to\n" " which to send ebooks. The first one that exists will be used:" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:148 +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:138 +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:224 +msgid "Browse for a folder on the device" +msgstr "" + +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:166 +msgid "" +"Select the devices to be ignored. calibre will not\n" +" connect to devices with a checkmark next to their names." +msgstr "" + +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:211 +msgid "Send the " +msgstr "" + +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:215 +msgid " format to the folder: " +msgstr "" + +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:218 +msgid "Folder on the device" +msgstr "" + +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:226 +msgid "&Remove rule" +msgstr "" + +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:271 +msgid "Format specific sending" +msgstr "" + +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:276 +msgid "" +"You can create rules that control where ebooks of a specific\n" +" format are sent to on the device. These will take precedence over\n" +" the folders specified above." +msgstr "" + +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:298 +msgid "Add a &new rule" +msgstr "" + +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:336 #, python-format msgid "The %s device has no serial number, it cannot be configured" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:153 +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:341 msgid "No MTP device connected.

You can only configure the MTP device plugin when a device is connected." msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:160 +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:348 msgid "If you want to un-ignore a previously ignored MTP device, use the \"Ignored devices\" tab." msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:176 +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:368 #, python-format msgid "Choose the formats to send to the %s" msgstr "" +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:371 +#, python-format +msgid "&Ignore the %s in calibre" +msgstr "" + +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:386 +msgid "Ignored devices" +msgstr "" + +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:393 +#, python-format +msgid "The %s will be ignored in calibre" +msgstr "" + +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_folder_browser.py:91 +msgid "Choose folder on device" +msgstr "" + #: /home/kovid/work/calibre/src/calibre/gui2/dialogs/add_empty_book.py:19 msgid "How many empty books?" msgstr "" @@ -8549,7 +8618,7 @@ msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/dialogs/edit_authors_dialog.py:122 #: /home/kovid/work/calibre/src/calibre/gui2/lrf_renderer/main.py:160 #: /home/kovid/work/calibre/src/calibre/gui2/metadata/single_download.py:523 -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:672 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:675 msgid "No matches found" msgstr "" @@ -8719,7 +8788,7 @@ msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/dialogs/message_box.py:103 #: /home/kovid/work/calibre/src/calibre/gui2/dialogs/message_box.py:335 -#: /home/kovid/work/calibre/src/calibre/gui2/proceed.py:79 +#: /home/kovid/work/calibre/src/calibre/gui2/proceed.py:82 #: /home/kovid/work/calibre/src/calibre/gui2/wizard/__init__.py:595 msgid "Copied" msgstr "" @@ -8727,7 +8796,7 @@ msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/dialogs/message_box.py:141 #: /home/kovid/work/calibre/src/calibre/gui2/metadata/single_download.py:880 #: /home/kovid/work/calibre/src/calibre/gui2/preferences/tweaks.py:344 -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:214 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:220 msgid "Copy to clipboard" msgstr "" @@ -9542,8 +9611,8 @@ msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/dialogs/quickview.py:87 #: /home/kovid/work/calibre/src/calibre/gui2/dialogs/tag_categories.py:60 #: /home/kovid/work/calibre/src/calibre/gui2/preferences/metadata_sources.py:156 -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:288 -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:1254 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:290 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:1256 #: /home/kovid/work/calibre/src/calibre/library/field_metadata.py:113 msgid "Authors" msgstr "" @@ -11232,24 +11301,24 @@ msgid "LRF Viewer toolbar" msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/lrf_renderer/main_ui.py:131 -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/documentview.py:514 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/documentview.py:516 msgid "Next Page" msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/lrf_renderer/main_ui.py:132 -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/documentview.py:515 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/documentview.py:517 msgid "Previous Page" msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/lrf_renderer/main_ui.py:133 #: /home/kovid/work/calibre/src/calibre/gui2/metadata/single_download.py:941 #: /home/kovid/work/calibre/src/calibre/gui2/store/web_store_dialog_ui.py:62 -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:202 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:208 msgid "Back" msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/lrf_renderer/main_ui.py:134 -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:203 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:209 msgid "Forward" msgstr "" @@ -11258,7 +11327,7 @@ msgid "Next match" msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/lrf_renderer/main_ui.py:136 -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:210 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:216 msgid "Open ebook" msgstr "" @@ -15096,12 +15165,12 @@ msgid "Options to customize the ebook viewer" msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/viewer/config.py:30 -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:1050 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:1068 msgid "Remember last used window size" msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/viewer/config.py:32 -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/config.py:90 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/config.py:93 msgid "Set the user CSS stylesheet. This can be used to customize the look of all books." msgstr "" @@ -15174,38 +15243,38 @@ msgstr "" msgid "The standard font type" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/config.py:130 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/config.py:133 msgid "Theme name" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/config.py:131 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/config.py:134 msgid "Choose a name for this theme" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/config.py:140 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/config.py:143 #, python-format msgid "Saved settings as the theme named: %s" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/config.py:156 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/config.py:159 #, python-format msgid "Loaded settings from the theme %s" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/config.py:163 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/config.py:166 #, python-format msgid "Deleted the theme named: %s" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/config.py:219 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/config.py:222 msgid "Choose text color" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/config.py:239 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/config.py:242 msgid "Still editing" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/config.py:240 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/config.py:243 msgid "You are in the middle of editing a keyboard shortcut first complete that, by clicking outside the shortcut editing box." msgstr "" @@ -15405,44 +15474,44 @@ msgstr "" msgid "No results found for:" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/documentview.py:480 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/documentview.py:482 msgid "&Lookup in dictionary" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/documentview.py:485 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/documentview.py:487 msgid "View &image..." msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/documentview.py:488 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/documentview.py:490 msgid "&Search for next occurrence" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/documentview.py:493 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/documentview.py:495 #: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:138 msgid "Go to..." msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/documentview.py:505 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/documentview.py:507 msgid "Next Section" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/documentview.py:506 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/documentview.py:508 msgid "Previous Section" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/documentview.py:508 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/documentview.py:510 msgid "Document Start" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/documentview.py:509 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/documentview.py:511 msgid "Document End" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/documentview.py:511 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/documentview.py:513 msgid "Section Start" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/documentview.py:512 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/documentview.py:514 msgid "Section End" msgstr "" @@ -15548,200 +15617,208 @@ msgstr "" msgid "Toggle full screen (%s)" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:279 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:282 msgid "Full screen mode" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:280 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:283 msgid "Right click to show controls" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:281 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:284 msgid "Tap in the left or right page margin to turn pages" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:282 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:285 msgid "Press Esc to quit" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:296 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:299 msgid "Show/hide controls" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:325 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:328 msgid "Print Preview" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:335 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:338 msgid "Clear list of recently opened books" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:446 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:449 #, python-format msgid "Connecting to dict.org to lookup: %s…" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:580 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:583 msgid "No such location" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:581 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:584 msgid "The location pointed to by this item does not exist." msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:632 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:635 msgid "Choose ebook" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:633 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:636 msgid "Ebooks" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:653 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:656 #, python-format msgid "" "Make font size %(which)s\n" "Current magnification: %(mag).1f" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:655 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:658 msgid "larger" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:657 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:660 msgid "smaller" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:673 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:676 #, python-format msgid "No matches found for: %s" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:722 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:725 msgid "Loading flow..." msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:800 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:803 #, python-format msgid "Laying out %s" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:852 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:870 #, python-format msgid "Bookmark #%d" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:856 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:874 msgid "Add bookmark" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:857 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:875 msgid "Enter title for bookmark:" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:868 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:886 msgid "Manage Bookmarks" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:910 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:928 msgid "Loading ebook..." msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:922 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:940 msgid "Could not open ebook" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:1037 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:1055 msgid "Options to control the ebook viewer" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:1044 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:1062 msgid "If specified, viewer window will try to come to the front when started." msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:1047 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:1065 msgid "If specified, viewer window will try to open full screen when started." msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:1052 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:1070 msgid "Print javascript alert and console messages to the console" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:1054 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:1072 msgid "The position at which to open the specified book. The position is a location as displayed in the top left corner of the viewer." msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:1061 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:1079 msgid "" "%prog [options] file\n" "\n" "View an ebook.\n" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:198 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:204 msgid "E-book Viewer" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:199 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:205 msgid "Close dictionary" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:201 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:207 msgid "toolBar" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:204 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:210 msgid "Next page" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:205 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:211 msgid "Previous page" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:206 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:212 msgid "Font size larger" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:207 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:213 msgid "Font size smaller" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:211 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:217 msgid "Find next" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:212 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:218 msgid "Find next occurrence" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:216 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:222 msgid "Reference Mode" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:217 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:223 msgid "Bookmark" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:218 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:224 msgid "Toggle full screen" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:219 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:225 msgid "Print" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:220 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:226 msgid "Find previous" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:221 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:227 msgid "Find previous occurrence" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:223 +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:229 msgid "Toggle Paged mode" msgstr "" +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:230 +msgid "Load theme" +msgstr "" + +#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:231 +msgid "Load a theme" +msgstr "" + #: /home/kovid/work/calibre/src/calibre/gui2/viewer/printing.py:66 msgid "Failed to render" msgstr "" @@ -16382,164 +16459,164 @@ msgstr "" msgid "Symbols" msgstr "" -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:273 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:275 msgid "No genres to catalog.\n" msgstr "" -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:275 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:277 msgid "Check 'Excluded genres' regex in E-book options.\n" msgstr "" -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:277 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:279 msgid "No books available to catalog" msgstr "" -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:290 -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:2313 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:292 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:2315 msgid "Titles" msgstr "" -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:294 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:296 msgid "Genres" msgstr "" -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:296 -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:1615 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:298 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:1617 msgid "Recently Added" msgstr "" -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:298 -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:1814 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:300 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:1816 msgid "Recently Read" msgstr "" -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:300 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:302 msgid "Descriptions" msgstr "" -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:525 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:527 msgid "

Inconsistent Author Sort values for Author
" msgstr "" -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:542 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:544 msgid "Warning: Inconsistent Author Sort values for Author '{!s}':\n" msgstr "" -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:676 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:678 msgid "Sorting database" msgstr "" -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:751 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:753 msgid "Sorting titles" msgstr "" -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:763 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:765 msgid "" "No books to catalog.\n" "Check 'Excluded books' rules in E-book options.\n" msgstr "" -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:765 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:767 msgid "No books available to include in catalog" msgstr "" -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:1895 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:1897 msgid "Genres HTML" msgstr "" -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:2293 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:2295 msgid "Titles HTML" msgstr "" -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:2488 -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:2490 #: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:2492 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:2494 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:2496 msgid "by " msgstr "" -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:2629 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:2633 msgid "Descriptions HTML" msgstr "" -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:2633 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:2637 msgid "Description HTML" msgstr "" -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:2768 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:2772 msgid "NCX header" msgstr "" -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:2843 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:2847 msgid "NCX for Descriptions" msgstr "" -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:2964 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:2968 msgid "NCX for Series" msgstr "" -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:3041 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:3045 #, python-format msgid "Series beginning with %s" msgstr "" -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:3043 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:3047 #, python-format msgid "Series beginning with '%s'" msgstr "" -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:3087 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:3091 msgid "NCX for Titles" msgstr "" -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:3166 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:3170 #, python-format msgid "Titles beginning with %s" msgstr "" -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:3168 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:3172 #, python-format msgid "Titles beginning with '%s'" msgstr "" -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:3210 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:3214 msgid "NCX for Authors" msgstr "" -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:3281 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:3285 #, python-format msgid "Authors beginning with %s" msgstr "" -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:3283 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:3287 #, python-format msgid "Authors beginning with '%s'" msgstr "" -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:3324 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:3328 msgid "NCX for Recently Added" msgstr "" -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:3511 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:3515 msgid "NCX for Recently Read" msgstr "" -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:3648 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:3652 msgid "NCX for Genres" msgstr "" -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:3766 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:3770 msgid "Generating OPF" msgstr "" -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:4138 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:4148 msgid "Thumbnails" msgstr "" -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:4144 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:4154 msgid "Thumbnail" msgstr "" -#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:4641 +#: /home/kovid/work/calibre/src/calibre/library/catalogs/epub_mobi_builder.py:4651 msgid "Saving NCX" msgstr "" From 987b0a28ac60d6aa6bc4fbe1f2f20a461804b59c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 14 Sep 2012 14:07:53 +0530 Subject: [PATCH 05/41] Update to libmtp 1.1.5 --- .../devices/mtp/unix/upstream/music-players.h | 228 ++++++++++-------- 1 file changed, 134 insertions(+), 94 deletions(-) diff --git a/src/calibre/devices/mtp/unix/upstream/music-players.h b/src/calibre/devices/mtp/unix/upstream/music-players.h index 69f43f8145..888d22551a 100644 --- a/src/calibre/devices/mtp/unix/upstream/music-players.h +++ b/src/calibre/devices/mtp/unix/upstream/music-players.h @@ -292,13 +292,7 @@ DEVICE_FLAG_PLAYLIST_SPL_V1 | DEVICE_FLAG_UNIQUE_FILENAMES | DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST }, - // From qnub - // Guessing on .spl flag - { "Samsung", 0x04e8, "YP-R2", 0x512d, - DEVICE_FLAG_UNLOAD_DRIVER | - DEVICE_FLAG_PLAYLIST_SPL_V1 | - DEVICE_FLAG_UNIQUE_FILENAMES | - DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST }, + // The "YP-R2" (0x04e8/0x512d) is NOT MTP, it is UMS only. // From Manuel Carro // Copied from Q2 { "Samsung", 0x04e8, "YP-Q3", 0x5130, @@ -357,25 +351,30 @@ { "Samsung", 0x04e8, "GT-S8500", 0x6819, DEVICE_FLAG_UNLOAD_DRIVER | DEVICE_FLAG_PLAYLIST_SPL_V1 }, - // From Harrison Metzger - { "Samsung", 0x04e8, - "Galaxy Nexus/Galaxy S i9000/i9250, Android 4.0 updates", 0x685c, - DEVICE_FLAGS_ANDROID_BUGS | - DEVICE_FLAG_PLAYLIST_SPL_V2 }, - // Reported by David Goodenough - // Guessing on flags. - { "Samsung", 0x04e8, "Galaxy Y", 0x685e, - DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL | - DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST | - DEVICE_FLAG_UNLOAD_DRIVER | - DEVICE_FLAG_LONG_TIMEOUT | - DEVICE_FLAG_PROPLIST_OVERRIDES_OI }, /* - * This entry (device 0x6860) seems to be used on a *lot* of Samsung - * Android (gingerbread, 2.3) phones. It is *not* the Android MTP stack - * but an internal Samsung stack. + * These entries seems to be used on a *lot* of Samsung + * Android phones. It is *not* the Android MTP stack but an internal + * Samsung stack. The devices present a few different product IDs + * depending on mode: * - * Popular devices: Galaxy S2 and S3. + * 0x685b - UMS + * 0x685c - MTP + ADB + * 0x685e - UMS + CDC + * 0x6860 - MTP mode (default) + * 0x6863 - USB CDC RNDIS (not MTP) + * 0x6865 - PTP mode (not MTP) + * 0x6877 - Kies mode? Does it have MTP? + * + * Used on these samsung devices: + * GT P7310/P7510/N7000/I9100/I9250/I9300 + * Galaxy Nexus + * Galaxy Tab 7.7/10.1 + * Galaxy S GT-I9000 + * Galaxy S Advance GT-I9070 + * Galaxy S2 + * Galaxy S3 + * Galaxy Note + * Galaxy Y * * - It seems that some PTP commands are broken. * - Devices seem to have a connection timeout, the session must be @@ -385,15 +384,30 @@ * US markets for some weird reason. * * From: Ignacio Martínez and others + * From Harrison Metzger */ { "Samsung", 0x04e8, - "GT P7310/P7510/N7000/I9070/I9100/I9300 Galaxy Tab 7.7/10.1/S2/S3/Nexus/Note/Y", 0x6860, + "Galaxy models (MTP+ADB)", 0x685c, + DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL | + DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST | + DEVICE_FLAG_UNLOAD_DRIVER | + DEVICE_FLAG_LONG_TIMEOUT | + DEVICE_FLAG_PROPLIST_OVERRIDES_OI }, + // Reported by David Goodenough + // Guessing on flags. + { "Samsung", 0x04e8, "Galaxy Y", 0x685e, + DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL | + DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST | + DEVICE_FLAG_UNLOAD_DRIVER | + DEVICE_FLAG_LONG_TIMEOUT | + DEVICE_FLAG_PROPLIST_OVERRIDES_OI }, + { "Samsung", 0x04e8, + "Galaxy models (MTP)", 0x6860, DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL | DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST | DEVICE_FLAG_UNLOAD_DRIVER | DEVICE_FLAG_LONG_TIMEOUT | DEVICE_FLAG_PROPLIST_OVERRIDES_OI }, - // Note: ID 0x6865 is some PTP mode! Don't add it. // From: Erik Berglund // Logs indicate this needs DEVICE_FLAG_NO_ZERO_READS // No Samsung platlists on this device. @@ -401,7 +415,7 @@ // i5800 duplicate reported by igel // Guessing this has the same problematic MTP stack as the device // above. - { "Samsung", 0x04e8, "Galaxy S GT-I9000/Galaxy 3 i5800/Kies mode", 0x6877, + { "Samsung", 0x04e8, "Galaxy models Kies mode", 0x6877, DEVICE_FLAG_UNLOAD_DRIVER | DEVICE_FLAG_LONG_TIMEOUT | DEVICE_FLAG_PROPLIST_OVERRIDES_OI }, @@ -526,6 +540,9 @@ { "Acer", 0x0502, "Iconia TAB A200 (ID2)", 0x337d, DEVICE_FLAGS_ANDROID_BUGS }, // Reported by nE0sIghT { "Acer", 0x0502, "Iconia TAB A510", 0x338a, DEVICE_FLAGS_ANDROID_BUGS }, + // Reported by Maxime de Roucy + { "Acer", 0x0502, "E350 Liquid Gallant Duo", 0x33c3, + DEVICE_FLAGS_ANDROID_BUGS }, /* * SanDisk @@ -859,6 +876,7 @@ { "Archos", 0x0e79, "SPOD (MTP mode)", 0x1341, DEVICE_FLAG_UNLOAD_DRIVER }, { "Archos", 0x0e79, "5S IT (MTP mode)", 0x1351, DEVICE_FLAG_UNLOAD_DRIVER }, { "Archos", 0x0e79, "5H IT (MTP mode)", 0x1357, DEVICE_FLAG_UNLOAD_DRIVER }, + { "Archos", 0x0e79, "Arnova Childpad", 0x1458, DEVICE_FLAG_UNLOAD_DRIVER }, // Reported by anonymous Sourceforge user { "Archos", 0x0e79, "8o G9 (MTP mode)", 0x1508, DEVICE_FLAG_UNLOAD_DRIVER }, // Reported by Clément @@ -1264,6 +1282,9 @@ { "LG Electronics Inc.", 0x1004, "V909 G-Slate", 0x61f9, DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST | DEVICE_FLAG_UNLOAD_DRIVER }, + // Reported by Brian J. Murrell + { "LG Electronics Inc.", 0x1004, "LG-E617G/P700", 0x631c, + DEVICE_FLAGS_ANDROID_BUGS }, /* * Sony @@ -1346,6 +1367,9 @@ // Reported by Jan Rheinlaender { "Sony", 0x054c, "NWZ-S765", 0x05a8, DEVICE_FLAGS_SONY_NWZ_BUGS }, + // Olivier Keshavjee + { "Sony", 0x054c, "Sony Tablet S", 0x05b3, + DEVICE_FLAGS_ANDROID_BUGS }, // Reported by ghalambaz { "Sony", 0x054c, "Sony Tablet S1", 0x05b4, DEVICE_FLAGS_ANDROID_BUGS }, @@ -1430,7 +1454,7 @@ * Legend: * MTP = Media Transfer Protocol * UMS = USB Mass Storage Protocol - * ADB = Android Debug Bridhe Protocol + * ADB = Android Debug Bridge Protocol * CDC = Communications Device Class, Internet Sharing * * 0x0nnn = MTP @@ -1450,120 +1474,103 @@ * detection has to be more elaborate. The code in libmtp.c will do * this and assign the proper bug flags (hopefully). * That is why DEVICE_FLAG_NONE is used for these devices. + * + * Devices reported by: + * Jonas Salling + * Eamonn Webster + * Alejandro DC + * StehpanKa + * hdhoang + * Paul Taylor + * Bruno Basilio + * Christoffer Holmstedt + * equaeghe + * Ondra Lengal + * Michael K. + * Jean-François B. + * Eduard Bloch + * Ah Hong */ - // Reported by Jonas Salling <> - // Erroneous MTP implementation seems to be from Aricent, returns - // broken transaction ID. { "SonyEricsson", 0x0fce, "LT15i (Xperia arc S)", 0x014f, DEVICE_FLAG_NONE }, - // Reported by Eamonn Webster - // Runtime detect the Aricent or Android stack { "SonyEricsson", 0x0fce, "MT11i Xperia Neo", 0x0156, DEVICE_FLAG_NONE }, - // Reported by Alejandro DC - // Runtime detect the Aricent or Android stack { "SonyEricsson", 0x0fce, "MK16i Xperia", 0x015a, DEVICE_FLAG_NONE }, - // Reported by - // Runtime detect the Aricent or Android stack { "SonyEricsson", 0x0fce, "ST18a Xperia Ray", 0x0161, DEVICE_FLAG_NONE }, - /* - * Reported by StehpanKa - * Android with homebrew MTP stack in one firmware, possibly Aricent - * Android with Android stack in another one, so let the run-time - * detector look up the device bug flags, set to NONE initially. - */ { "SonyEricsson", 0x0fce, "SK17i Xperia Mini Pro", 0x0166, DEVICE_FLAG_NONE }, - // Reported by hdhoang - // Runtime detect the Aricent or Android stack { "SonyEricsson", 0x0fce, "ST15i Xperia Mini", 0x0167, DEVICE_FLAG_NONE }, - // Reported by Paul Taylor - { "SONY", 0x0fce, "Xperia S", 0x0169, + { "SonyEricsson", 0x0fce, "ST17i Xperia Active", 0x0168, + DEVICE_FLAG_NONE }, + { "SONY", 0x0fce, "LT26i Xperia S", 0x0169, DEVICE_FLAG_NO_ZERO_READS }, - // Reported by Bruno Basilio { "SONY", 0x0fce, "WT19i Live Walkman", 0x016d, DEVICE_FLAG_NONE }, - // Reported by Christoffer Holmstedt { "SONY", 0x0fce, "ST21i Xperia Tipo", 0x0170, DEVICE_FLAG_NONE }, - // Reported by equaeghe { "SONY", 0x0fce, "ST15i Xperia U", 0x0171, DEVICE_FLAG_NONE }, - // Reported by Ondra Lengal - { "SONY", 0x0fce, "Xperia P", 0x0172, + { "SONY", 0x0fce, "LT22i Xperia P", 0x0172, DEVICE_FLAG_NONE }, - // Guessing on this one { "SONY", 0x0fce, "LT26w Xperia Acro S", 0x0176, DEVICE_FLAG_NONE }, /* - * MTP+MSC personalities of MTP devices (see above) + * MTP+UMS personalities of MTP devices (see above) */ - // Guessing on this one - { "SONY", 0x0fce, "Xperia S (MTP+ADB mode)", 0x4169, + { "SonyEricsson", 0x0fce, "ST17i Xperia Active (MTP+UMS mode)", 0x4168, + DEVICE_FLAG_NONE }, + { "SONY", 0x0fce, "LT26i Xperia S (MTP+UMS mode)", 0x4169, DEVICE_FLAG_NO_ZERO_READS }, - // Guessing on this one - { "SONY", 0x0fce, "ST21i Xperia Tipo (MTP+MSC mode)", 0x4170, + { "SONY", 0x0fce, "ST21i Xperia Tipo (MTP+UMS mode)", 0x4170, DEVICE_FLAG_NONE }, - // Reported by equaeghe - { "SONY", 0x0fce, "ST25i Xperia U (MTP+MSC mode)", 0x4171, + { "SONY", 0x0fce, "ST25i Xperia U (MTP+UMS mode)", 0x4171, DEVICE_FLAG_NONE }, - // Guessing on this one - { "SONY", 0x0fce, "Xperia P (MTP+MSC mode)", 0x4172, + { "SONY", 0x0fce, "LT22i Xperia P (MTP+UMS mode)", 0x4172, DEVICE_FLAG_NONE }, - // Guessing on this one - { "SONY", 0x0fce, "LT26w Xperia Acro S (MTP+MSC mode)", 0x4176, + { "SONY", 0x0fce, "LT26w Xperia Acro S (MTP+UMS mode)", 0x4176, DEVICE_FLAG_NONE }, /* * MTP+ADB personalities of MTP devices (see above) */ - // Reported by anonymous sourceforge user - // Suspect Aricent stack, guessing on these bug flags { "SonyEricsson", 0x0fce, "LT15i Xperia Arc (MTP+ADB mode)", 0x514f, DEVICE_FLAG_NONE }, - // Reported by Michael K. - // Runtime detect the Aricent or Android stack { "SonyEricsson", 0x0fce, "MT11i Xperia Neo (MTP+ADB mode)", 0x5156, DEVICE_FLAG_NONE }, - // Reported by Jean-François B. - { "SONY", 0x0fce, "Xperia S (MTP+ADB mode)", 0x5169, + { "SonyEricsson", 0x0fce, "ST17i Xperia Active (MTP+ADB mode)", 0x5168, + DEVICE_FLAG_NONE }, + { "SONY", 0x0fce, "LT26i Xperia S (MTP+ADB mode)", 0x5169, DEVICE_FLAG_NO_ZERO_READS }, - // Runtime detect the Aricent or Android stack { "SonyEricsson", 0x0fce, "MK16i Xperia (MTP+ADB mode)", 0x515a, DEVICE_FLAG_NONE }, - // Reported by Eduard Bloch - // Xperia Ray (2012), SE Android 2.3.4, flags from ST18a - // Runtime detect the Aricent or Android stack { "SonyEricsson", 0x0fce, "ST18i Xperia Ray (MTP+ADB mode)", 0x5161, DEVICE_FLAG_NONE }, - // Reported by StehpanKa - // Android with homebrew MTP stack, possibly Aricent - // Runtime detect the Aricent or Android stack { "SonyEricsson", 0x0fce, "SK17i Xperia Mini Pro (MTP+ADB mode)", 0x5166, DEVICE_FLAG_NONE }, - // Android with homebrew MTP stack, possibly Aricent - // Runtime detect the Aricent or Android stack { "SonyEricsson", 0x0fce, "ST15i Xperia Mini (MTP+ADB mode)", 0x5167, DEVICE_FLAG_NONE }, - { "SonyEricsson", 0x0fce, "SK17i Xperia Mini Pro (MTP+? mode)", 0x516d, + { "SonyEricsson", 0x0fce, "SK17i Xperia Mini Pro (MTP+ADB mode)", 0x516d, DEVICE_FLAG_NONE }, - // Guessing on this one { "SONY", 0x0fce, "ST21i Xperia Tipo (MTP+ADB mode)", 0x5170, DEVICE_FLAG_NONE }, - // Reported by equaeghe { "SONY", 0x0fce, "ST25i Xperia U (MTP+ADB mode)", 0x5171, DEVICE_FLAG_NONE }, - // Reported by Ondra Lengál - { "SONY", 0x0fce, "Xperia P (MTP+ADB mode)", 0x5172, + { "SONY", 0x0fce, "LT22i Xperia P (MTP+ADB mode)", 0x5172, DEVICE_FLAG_NONE }, - // Reported by Ah Hong { "SONY", 0x0fce, "LT26w Xperia Acro S (MTP+ADB mode)", 0x5176, DEVICE_FLAG_NONE }, - { "SONY", 0x0fce, "MT27i Xperia Sola (MTP+MSC+? mode)", 0xa173, + + /* + * MTP+UMS+? modes + * No reports on other personalities on these devices. + */ + { "SONY", 0x0fce, "MT27i Xperia Sola (MTP+UMS+? mode)", 0xa173, + DEVICE_FLAG_NONE }, + { "SONY", 0x0fce, "ST27i Xperia Go (MTP+UMS+? mode)", 0xa17e, DEVICE_FLAG_NONE }, /* @@ -1591,6 +1598,9 @@ // Reported by B,H,Kissinger { "Motorola", 0x22b8, "XT912/XT928", 0x4362, DEVICE_FLAGS_ANDROID_BUGS }, + // Reported by Lundgren + { "Motorola", 0x22b8, "DROID4", 0x437f, + DEVICE_FLAGS_ANDROID_BUGS }, // Reported by Marcus Meissner to libptp2 { "Motorola", 0x22b8, "IdeaPad K1", 0x4811, DEVICE_FLAG_BROKEN_SET_OBJECT_PROPLIST }, @@ -1603,10 +1613,32 @@ // Reported by anonymous user { "Motorola", 0x22b8, "RAZR2 V8/U9/Z6", 0x6415, DEVICE_FLAG_BROKEN_SET_OBJECT_PROPLIST }, - // Reported by Google Inc's Yavor Goulishev - // Android 3.0 MTP stack seems to announce that it supports the - // list operations, but they do not work? - { "Motorola", 0x22b8, "Xoom (ID 1)", 0x70a8, DEVICE_FLAGS_ANDROID_BUGS }, + /* + * Motorola Xoom (Wingray) variants + * + * These devices seem to use these product IDs simulatenously + * https://code.google.com/p/android-source-browsing/source/browse/init.stingray.usb.rc?repo=device--moto--wingray + * + * 0x70a3 - Factory test - reported as early MTP ID + * 0x70a8 - MTP + * 0x70a9 - MTP+ADB + * 0x70ae - RNDIS + * 0x70af - RNDIS+ADB + * 0x70b0 - ACM + * 0x70b1 - ACM+ADB + * 0x70b2 - ACM+RNDIS + * 0x70b3 - ACM+RNDIS+ADB + * 0x70b4 - PTP + * 0x70b5 - PTP+ADB + * + * Reported by Google Inc's Yavor Goulishev + */ + { "Motorola", 0x22b8, "Xoom (Factory test)", 0x70a3, + DEVICE_FLAGS_ANDROID_BUGS }, + { "Motorola", 0x22b8, "Xoom (MTP)", 0x70a8, + DEVICE_FLAGS_ANDROID_BUGS }, + { "Motorola", 0x22b8, "Xoom (MTP+ADB)", 0x70a9, + DEVICE_FLAGS_ANDROID_BUGS }, // Reported by anonymous Sourceforge user // "carried by C Spire and other CDMA US carriers" { "Motorola", 0x22b8, "Milestone X2", 0x70ca, DEVICE_FLAGS_ANDROID_BUGS }, @@ -1629,17 +1661,15 @@ { "Google Inc (for Samsung)", 0x18d1, "Nexus S", 0x4e21, DEVICE_FLAGS_ANDROID_BUGS }, // Reported by Chris Smith - { "Google Inc (for Asus)", 0x18d1, "Nexus 7 (mode 1)", 0x4e41, + { "Google Inc (for Asus)", 0x18d1, "Nexus 7 (MTP)", 0x4e41, DEVICE_FLAGS_ANDROID_BUGS }, // Reported by Michael Hess - { "Google Inc (for Asus)", 0x18d1, "Nexus 7 (mode 2)", 0x4e42, + { "Google Inc (for Asus)", 0x18d1, "Nexus 7 (MTP+ADB)", 0x4e42, DEVICE_FLAGS_ANDROID_BUGS }, // WiFi-only version of Xoom // See: http://bugzilla.gnome.org/show_bug.cgi?id=647506 { "Google Inc (for Motorola)", 0x18d1, "Xoom (MZ604)", 0x70a8, DEVICE_FLAGS_ANDROID_BUGS }, - { "Google Inc (for Motorola)", 0x22b8, "Xoom (ID 2)", 0x70a9, - DEVICE_FLAGS_ANDROID_BUGS }, { "Google Inc (for Toshiba)", 0x18d1, "Thrive 7/AT105", 0x7102, DEVICE_FLAGS_ANDROID_BUGS }, { "Google Inc (for Lenovo)", 0x18d1, "Ideapad K1", 0x740a, @@ -1769,6 +1799,9 @@ // Reported by jaile { "Asus", 0x0b05, "TF300 Transformer (USB debug mode)", 0x4c81, DEVICE_FLAGS_ANDROID_BUGS }, + // Repored by Florian Apolloner + { "Asus", 0x0b05, "TF700 Transformer", 0x4c90, + DEVICE_FLAGS_ANDROID_BUGS }, // Reported by anonymous Sourceforge user { "Asus", 0x0b05, "TF201 Transformer Prime (keyboard dock)", 0x4d00, DEVICE_FLAGS_ANDROID_BUGS }, @@ -1795,6 +1828,13 @@ // Adding Android default bug flags since it appears to be an Android { "Lenovo", 0x17ef, "ThinkPad Tablet", 0x741c, DEVICE_FLAGS_ANDROID_BUGS }, + // Reported by: XChesser + { "Lenovo", 0x17ef, "P700", 0x7497, + DEVICE_FLAGS_ANDROID_BUGS }, + // Reported by: anonymous sourceforge user + { "Lenovo", 0x17ef, "Lifetab S9512", 0x74cc, + DEVICE_FLAGS_ANDROID_BUGS }, + /* * Huawei From 8b85e25020e5d4426df9e2ad16f231805bb1301d Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 14 Sep 2012 14:35:45 +0530 Subject: [PATCH 06/41] Make author sorting on the device case insensitive --- src/calibre/devices/kobo/books.py | 2 ++ src/calibre/gui2/library/models.py | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/calibre/devices/kobo/books.py b/src/calibre/devices/kobo/books.py index 48033b3522..32bf9a9828 100644 --- a/src/calibre/devices/kobo/books.py +++ b/src/calibre/devices/kobo/books.py @@ -8,6 +8,7 @@ import time from calibre.utils.date import parse_date from calibre.devices.usbms.books import Book as Book_ +from calibre.ebooks.metadata import author_to_author_sort class Book(Book_): @@ -20,6 +21,7 @@ class Book(Book_): self.authors = [''] else: self.authors = [authors] + self.author_sort = author_to_author_sort(self.authors[0]) if not title: self.title = _('Unknown') diff --git a/src/calibre/gui2/library/models.py b/src/calibre/gui2/library/models.py index f0296a32c7..246b0835a5 100644 --- a/src/calibre/gui2/library/models.py +++ b/src/calibre/gui2/library/models.py @@ -1193,7 +1193,10 @@ class DeviceBooksModel(BooksModel): # {{{ ax = authors_to_string(self.db[x].authors) except: ax = '' - return ax + try: + return sort_key(ax) + except: + return ax keygen = { 'title': ('title_sorter', lambda x: sort_key(x) if x else ''), From 4e4a594fbad5c1dd98aa3814f4f352d0a871c764 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 14 Sep 2012 17:27:39 +0530 Subject: [PATCH 07/41] Fix #1050815 (wrong string for translation) --- src/calibre/gui2/device_drivers/mtp_config.py | 5 +- src/calibre/translations/calibre.pot | 55 +++++++++---------- 2 files changed, 29 insertions(+), 31 deletions(-) diff --git a/src/calibre/gui2/device_drivers/mtp_config.py b/src/calibre/gui2/device_drivers/mtp_config.py index 0187915a4a..c6d2154229 100644 --- a/src/calibre/gui2/device_drivers/mtp_config.py +++ b/src/calibre/gui2/device_drivers/mtp_config.py @@ -208,11 +208,12 @@ class Rule(QWidget): self.l = l = QHBoxLayout() self.setLayout(l) - self.l1 = l1 = QLabel(_('Send the ')) + p, s = _('Send the %s format to the folder:').partition('%s')[0::2] + self.l1 = l1 = QLabel(p) l.addWidget(l1) self.fmt = f = QComboBox(self) l.addWidget(f) - self.l2 = l2 = QLabel(_(' format to the folder: ')) + self.l2 = l2 = QLabel(s) l.addWidget(l2) self.folder = f = QLineEdit(self) f.setPlaceholderText(_('Folder on the device')) diff --git a/src/calibre/translations/calibre.pot b/src/calibre/translations/calibre.pot index c72755c50a..54af558052 100644 --- a/src/calibre/translations/calibre.pot +++ b/src/calibre/translations/calibre.pot @@ -5,8 +5,8 @@ msgid "" msgstr "" "Project-Id-Version: calibre 0.8.69\n" -"POT-Creation-Date: 2012-09-14 09:40+IST\n" -"PO-Revision-Date: 2012-09-14 09:40+IST\n" +"POT-Creation-Date: 2012-09-14 17:27+IST\n" +"PO-Revision-Date: 2012-09-14 17:27+IST\n" "Last-Translator: Automatically generated\n" "Language-Team: LANGUAGE\n" "MIME-Version: 1.0\n" @@ -30,7 +30,7 @@ msgstr "" #: /home/kovid/work/calibre/src/calibre/devices/hanvon/driver.py:101 #: /home/kovid/work/calibre/src/calibre/devices/jetbook/driver.py:74 #: /home/kovid/work/calibre/src/calibre/devices/kindle/driver.py:77 -#: /home/kovid/work/calibre/src/calibre/devices/kobo/books.py:25 +#: /home/kovid/work/calibre/src/calibre/devices/kobo/books.py:27 #: /home/kovid/work/calibre/src/calibre/devices/kobo/driver.py:656 #: /home/kovid/work/calibre/src/calibre/devices/mtp/books.py:44 #: /home/kovid/work/calibre/src/calibre/devices/mtp/unix/driver.py:204 @@ -155,10 +155,10 @@ msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/email.py:206 #: /home/kovid/work/calibre/src/calibre/gui2/library/models.py:408 #: /home/kovid/work/calibre/src/calibre/gui2/library/models.py:1062 -#: /home/kovid/work/calibre/src/calibre/gui2/library/models.py:1270 #: /home/kovid/work/calibre/src/calibre/gui2/library/models.py:1273 #: /home/kovid/work/calibre/src/calibre/gui2/library/models.py:1276 -#: /home/kovid/work/calibre/src/calibre/gui2/library/models.py:1364 +#: /home/kovid/work/calibre/src/calibre/gui2/library/models.py:1279 +#: /home/kovid/work/calibre/src/calibre/gui2/library/models.py:1367 #: /home/kovid/work/calibre/src/calibre/gui2/metadata/basic_widgets.py:84 #: /home/kovid/work/calibre/src/calibre/gui2/metadata/basic_widgets.py:245 #: /home/kovid/work/calibre/src/calibre/gui2/metadata/basic_widgets.py:256 @@ -204,7 +204,7 @@ msgstr "" #: /home/kovid/work/calibre/src/calibre/customize/__init__.py:156 #: /home/kovid/work/calibre/src/calibre/gui2/actions/preferences.py:54 #: /home/kovid/work/calibre/src/calibre/gui2/actions/preferences.py:59 -#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:355 +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:356 msgid "Cannot configure" msgstr "" @@ -7834,7 +7834,7 @@ msgid "Cannot configure the device while there are running device jobs." msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/device.py:897 -#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:358 +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:359 #, python-format msgid "Configure %s" msgstr "" @@ -8012,7 +8012,7 @@ msgid "" msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:138 -#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:224 +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:225 msgid "Browse for a folder on the device" msgstr "" @@ -8023,64 +8023,61 @@ msgid "" msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:211 -msgid "Send the " +#, python-format +msgid "Send the %s format to the folder:" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:215 -msgid " format to the folder: " -msgstr "" - -#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:218 +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:219 msgid "Folder on the device" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:226 +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:227 msgid "&Remove rule" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:271 +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:272 msgid "Format specific sending" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:276 +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:277 msgid "" "You can create rules that control where ebooks of a specific\n" " format are sent to on the device. These will take precedence over\n" " the folders specified above." msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:298 +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:299 msgid "Add a &new rule" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:336 +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:337 #, python-format msgid "The %s device has no serial number, it cannot be configured" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:341 +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:342 msgid "No MTP device connected.

You can only configure the MTP device plugin when a device is connected." msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:348 +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:349 msgid "If you want to un-ignore a previously ignored MTP device, use the \"Ignored devices\" tab." msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:368 +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:369 #, python-format msgid "Choose the formats to send to the %s" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:371 +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:372 #, python-format msgid "&Ignore the %s in calibre" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:386 +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:387 msgid "Ignored devices" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:393 +#: /home/kovid/work/calibre/src/calibre/gui2/device_drivers/mtp_config.py:394 #, python-format msgid "The %s will be ignored in calibre" msgstr "" @@ -11165,13 +11162,13 @@ msgid "Modified" msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/library/models.py:785 -#: /home/kovid/work/calibre/src/calibre/gui2/library/models.py:1400 +#: /home/kovid/work/calibre/src/calibre/gui2/library/models.py:1403 #: /home/kovid/work/calibre/src/calibre/gui2/tag_browser/model.py:312 msgid "The lookup/search name is \"{0}\"" msgstr "" #: /home/kovid/work/calibre/src/calibre/gui2/library/models.py:791 -#: /home/kovid/work/calibre/src/calibre/gui2/library/models.py:1402 +#: /home/kovid/work/calibre/src/calibre/gui2/library/models.py:1405 msgid "This book's UUID is \"{0}\"" msgstr "" @@ -11204,11 +11201,11 @@ msgstr "" msgid "Size" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/library/models.py:1382 +#: /home/kovid/work/calibre/src/calibre/gui2/library/models.py:1385 msgid "Marked for deletion" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/library/models.py:1385 +#: /home/kovid/work/calibre/src/calibre/gui2/library/models.py:1388 msgid "Double click to edit me

" msgstr "" From 87fc87978bc88e6b9e12f6da3dbabeab4b551043 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 14 Sep 2012 19:04:49 +0530 Subject: [PATCH 08/41] ... --- src/calibre/devices/mtp/filesystem_cache.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/devices/mtp/filesystem_cache.py b/src/calibre/devices/mtp/filesystem_cache.py index b1c2828b8c..dfabef06d9 100644 --- a/src/calibre/devices/mtp/filesystem_cache.py +++ b/src/calibre/devices/mtp/filesystem_cache.py @@ -204,7 +204,7 @@ class FilesystemCache(object): except KeyError: # Parent does not exist, set the parent to be the storage # object - sid = p.storage_id + sid = item.storage_id if sid not in all_storage_ids: sid = all_storage_ids[0] item.parent_id = sid From a7cab66b6f851d27e23d1799eecc85c6769aeca7 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Fri, 14 Sep 2012 17:47:38 +0200 Subject: [PATCH 09/41] Tweak XKCD recipe: Add a masthead image, put the strip title in an h1 tag --- recipes/xkcd.recipe | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/recipes/xkcd.recipe b/recipes/xkcd.recipe index 42dceda65b..2aa704992e 100644 --- a/recipes/xkcd.recipe +++ b/recipes/xkcd.recipe @@ -2,6 +2,8 @@ __license__ = 'GPL v3' __copyright__ = '2008, Kovid Goyal ' ''' Changelog: +2012-04-06 +Fixed empty articles, added masthead img (NiLuJe) 2011-09-24 Changed cover (drMerry) ''' @@ -13,7 +15,8 @@ import time, re from calibre.web.feeds.news import BasicNewsRecipe class XkcdCom(BasicNewsRecipe): - cover_url = 'http://imgs.xkcd.com/s/9be30a7.png' + cover_url = 'http://imgs.xkcd.com/static/terrible_small_logo.png' + masthead_url = 'http://imgs.xkcd.com/static/terrible_small_logo.png' title = 'xkcd' description = 'A webcomic of romance and math humor.' __author__ = 'Martin Pitt updated by DrMerry.' @@ -21,13 +24,14 @@ class XkcdCom(BasicNewsRecipe): use_embedded_content = False oldest_article = 60 - keep_only_tags = [dict(id='middleContainer')] - remove_tags = [dict(name='ul'), dict(name='h3'), dict(name='br')] + #keep_only_tags = [dict(id='middleContainer')] + #remove_tags = [dict(name='ul'), dict(name='h3'), dict(name='br')] + keep_only_tags = [dict(id='comic')] no_stylesheets = True - # turn image bubblehelp into a paragraph + # turn image bubblehelp into a paragraph, and put alt in a heading preprocess_regexps = [ - (re.compile(r'()'), - lambda m: '%s%s

%s

' % (m.group(1), m.group(3), m.group(2))) + (re.compile(r'()'), + lambda m: '

%s

%s%s%s

%s

' % (m.group(4), m.group(1), m.group(3), m.group(5), m.group(2))) ] def parse_index(self): From ad0123a2b03c4e7cf375dd45cb6f66f93615ac93 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Fri, 14 Sep 2012 17:49:03 +0200 Subject: [PATCH 10/41] Add a recipe for DogHouse Diaries, an online comic --- recipes/doghousediaries.recipe | 52 ++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 recipes/doghousediaries.recipe diff --git a/recipes/doghousediaries.recipe b/recipes/doghousediaries.recipe new file mode 100644 index 0000000000..e52db094b1 --- /dev/null +++ b/recipes/doghousediaries.recipe @@ -0,0 +1,52 @@ +__license__ = 'GPL v3' +__copyright__ = '2010-2012, NiLuJe ' + +''' +Fetch DoghouseDiaries. +''' + +import re +from calibre.web.feeds.news import BasicNewsRecipe + +class DoghouseDiaries(BasicNewsRecipe): + title = 'Doghouse Diaries' + description = 'A webcomic.' + __author__ = 'NiLuJe' + language = 'en' + + use_embedded_content = False + # 14 comics per fetch (not really days... but we can't easily get the date of individual comics, short of parsing each one...) + oldest_article = 14 + + cover_url = 'http://www.thedoghousediaries.com/logos/logo3.png' + masthead_url = 'http://www.thedoghousediaries.com/logos/logo3.png' + + keep_only_tags = [dict(name='img', attrs={'class': re.compile("comic-item*")}), dict(name='h1'), dict(name='div', attrs={'class':'entry'}), dict(name='p', id='alttext')] + remove_tags = [dict(name='div', attrs={'class':'pin-it-btn-wrapper'}), dict(name='span'), dict(name='div', id='wp_fb_like_button')] + remove_attributes = ['width', 'height'] + no_stylesheets = True + + # Turn image bubblehelp into a paragraph (NOTE: We run before the remove_tags cleanup, so we need to make sure we only parse the comic-item img, not the pinterest one pulled by the entry div) + preprocess_regexps = [ + (re.compile(r'()'), + lambda m: '%s%s

%s

' % (m.group(1), m.group(3), m.group(2))) + ] + + def parse_index(self): + INDEX = 'http://www.thedoghousediaries.com/' + + soup = self.index_to_soup(INDEX) + articles = [] + # Since the feed sucks, and there's no real archive, we use the 'Quick Archive' thingie, but we can't get the date from here, so stop after 14 comics... + for item in soup.findAll('option', {}, True, None, self.oldest_article+1): + # Skip the quick archive itself + if ( item['value'] != '0' ): + articles.append({ + 'title': self.tag_to_string(item).encode('UTF-8'), + 'url': item['value'], + 'description': '', + 'content': '', + }) + + return [('Doghouse Diaries', articles)] + From 6c42c0ea6cef09a945cd887e0af898d7bafc1733 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Fri, 14 Sep 2012 17:55:15 +0200 Subject: [PATCH 11/41] Produce an output more similar to Mobi Unpack when dumping a MOBI header --- src/calibre/ebooks/mobi/debug/headers.py | 120 ++++++++++++++--------- 1 file changed, 72 insertions(+), 48 deletions(-) diff --git a/src/calibre/ebooks/mobi/debug/headers.py b/src/calibre/ebooks/mobi/debug/headers.py index 5b80a46f1b..7e2fc6f3cb 100644 --- a/src/calibre/ebooks/mobi/debug/headers.py +++ b/src/calibre/ebooks/mobi/debug/headers.py @@ -116,61 +116,85 @@ class Record(object): # {{{ # EXTH {{{ class EXTHRecord(object): - def __init__(self, type_, data): + def __init__(self, type_, data, length): self.type = type_ self.data = data + self.length = length self.name = { - 1 : 'DRM Server id', - 2 : 'DRM Commerce id', - 3 : 'DRM ebookbase book id', - 100 : 'author', - 101 : 'publisher', - 102 : 'imprint', - 103 : 'description', - 104 : 'isbn', - 105 : 'subject', - 106 : 'publishingdate', - 107 : 'review', - 108 : 'contributor', - 109 : 'rights', - 110 : 'subjectcode', - 111 : 'type', - 112 : 'source', - 113 : 'asin', - 114 : 'versionnumber', + 1 : 'Drm Server Id', + 2 : 'Drm Commerce Id', + 3 : 'Drm Ebookbase Book Id', + 100 : 'Creator', + 101 : 'Publisher', + 102 : 'Imprint', + 103 : 'Description', + 104 : 'ISBN', + 105 : 'Subject', + 106 : 'Published', + 107 : 'Review', + 108 : 'Contributor', + 109 : 'Rights', + 110 : 'SubjectCode', + 111 : 'Type', + 112 : 'Source', + 113 : 'ASIN', + 114 : 'versionNumber', 115 : 'sample', - 116 : 'startreading', - 117 : 'adult', - 118 : 'retailprice', - 119 : 'retailpricecurrency', - 121 : 'KF8 header section index', - 125 : 'KF8 resources (images/fonts) count', - 129 : 'KF8 cover URI', - 131 : 'KF8 unknown count', - 201 : 'coveroffset', - 202 : 'thumboffset', - 203 : 'hasfakecover', + 116 : 'StartOffset', + 117 : 'Adult', + 118 : 'Price', + 119 : 'Currency', + 121 : 'KF8_Boundary_Section', + 122 : 'fixed-layout', + 123 : 'book-type', + 124 : 'orientation-lock', + 125 : 'KF8_Count_of_Resources_Fonts_Images', + 126 : 'original-resolution', + 127 : 'zero-gutter', + 128 : 'zero-margin', + 129 : 'KF8_Masthead/Cover_Image', + 131 : 'KF8_Unidentified_Count', + 132 : 'RegionMagnification', + 200 : 'DictShortName', + 201 : 'CoverOffset', + 202 : 'ThumbOffset', + 203 : 'Fake Cover', 204 : 'Creator Software', 205 : 'Creator Major Version', # '>I' 206 : 'Creator Minor Version', # '>I' 207 : 'Creator Build Number', # '>I' - 208 : 'watermark', - 209 : 'tamper_proof_keys', - 300 : 'fontsignature', - 301 : 'clippinglimit', # percentage '>B' - 402 : 'publisherlimit', - 404 : 'TTS flag', # '>B' 1 - TTS disabled 0 - TTS enabled - 501 : 'cdetype', # 4 chars (PDOC or EBOK) - 502 : 'lastupdatetime', - 503 : 'updatedtitle', - 524 : 'language', + 208 : 'Watermark', + 209 : 'Tamper Proof Keys [hex]', + 300 : 'Font Signature [hex]', + 301 : 'Clipping Limit [3xx]', # percentage '>B' + 401 : 'Clipping Limit', # percentage '>B' + 402 : 'Publisher Limit', + 404 : 'Text to Speech Disabled', # '>B' 1 - TTS disabled 0 - TTS enabled + 501 : 'CDE Type', # 4 chars (PDOC, EBOK, MAGZ, ...) + 502 : 'last_update_time', + 503 : 'Updated Title', + 504 : 'ASIN [5xx]', + 524 : 'Language', + 525 : 'TextDirection', + 528 : 'Unknown_Logical_Value', + 535 : 'Kindlegen Build-Rev Number', }.get(self.type, repr(self.type)) - if (self.name in {'coveroffset', 'thumboffset', 'hasfakecover', - 'Creator Major Version', 'Creator Minor Version', - 'Creator Build Number', 'Creator Software', 'startreading'} or + if (self.name in {'sample', 'StartOffset', 'CoverOffset', 'ThumbOffset', 'Fake Cover', + 'Creator Software', 'Creator Major Version', 'Creator Minor Version', + 'Creator Build Number', 'Clipping Limit (3xx)', 'Clipping Limit', + 'Publisher Limit', 'Text to Speech Disabled'} or self.type in {121, 125, 131}): - self.data, = struct.unpack(b'>I', self.data) + if self.length == 9: + self.data, = struct.unpack(b'>B', self.data) + elif self.length == 10: + self.data, = struct.unpack(b'>H', self.data) + elif self.length == 12: + self.data, = struct.unpack(b'>L', self.data) + else: + self.data, = struct.unpack(b'>I', self.data) # Assume I for unknown sizes... + elif self.type in {209, 300}: + self.data = bytes(self.data.encode('hex')) def __str__(self): return '%s (%d): %r'%(self.name, self.type, self.data) @@ -181,8 +205,8 @@ class EXTHHeader(object): self.raw = raw if not self.raw.startswith(b'EXTH'): raise ValueError('EXTH header does not start with EXTH') - self.length, = struct.unpack(b'>I', self.raw[4:8]) - self.count, = struct.unpack(b'>I', self.raw[8:12]) + self.length, = struct.unpack(b'>L', self.raw[4:8]) + self.count, = struct.unpack(b'>L', self.raw[8:12]) pos = 12 self.records = [] @@ -199,9 +223,9 @@ class EXTHHeader(object): return getattr(ans, 'data', default) def read_record(self, pos): - type_, length = struct.unpack(b'>II', self.raw[pos:pos+8]) + type_, length = struct.unpack(b'>LL', self.raw[pos:pos+8]) data = self.raw[(pos+8):(pos+length)] - self.records.append(EXTHRecord(type_, data)) + self.records.append(EXTHRecord(type_, data, length)) return pos + length @property From 8297eebb61a5b3987d4d4452dc22377b3ab89690 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Fri, 14 Sep 2012 17:56:15 +0200 Subject: [PATCH 12/41] Don't horribly die when dumping a mobi whose HTML content is not encoded in UTF-8 --- src/calibre/ebooks/mobi/debug/mobi6.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/ebooks/mobi/debug/mobi6.py b/src/calibre/ebooks/mobi/debug/mobi6.py index fb5674653c..938629e391 100644 --- a/src/calibre/ebooks/mobi/debug/mobi6.py +++ b/src/calibre/ebooks/mobi/debug/mobi6.py @@ -802,7 +802,7 @@ def inspect_mobi(mobi_file, ddir): alltext += rec.raw of.seek(0) - root = html.fromstring(alltext.decode('utf-8')) + root = html.fromstring(alltext.decode(f.mobi_header.encoding)) with open(os.path.join(ddir, 'pretty.html'), 'wb') as of: of.write(html.tostring(root, pretty_print=True, encoding='utf-8', include_meta_content_type=True)) From ca467cdb2ee2d7ed9c858e54dab6e64f321d514f Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Fri, 14 Sep 2012 17:58:09 +0200 Subject: [PATCH 13/41] Split each author into its own EXTH Creator field, even with the 'Use author_sort as author' setting. Also, in a slightly unrelated note, sprinkle azw3 awareness in a few places. --- src/calibre/ebooks/__init__.py | 2 +- src/calibre/ebooks/metadata/archive.py | 2 +- src/calibre/ebooks/metadata/meta.py | 4 ++-- src/calibre/ebooks/metadata/mobi.py | 12 ++++++++---- src/calibre/ebooks/metadata/rar.py | 2 +- src/calibre/ebooks/metadata/zip.py | 2 +- src/calibre/ebooks/mobi/writer8/exth.py | 10 +++++++++- src/calibre/gui2/actions/add.py | 2 +- src/calibre/gui2/wizard/__init__.py | 2 +- 9 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/calibre/ebooks/__init__.py b/src/calibre/ebooks/__init__.py index da820cffbb..ee880000f0 100644 --- a/src/calibre/ebooks/__init__.py +++ b/src/calibre/ebooks/__init__.py @@ -163,7 +163,7 @@ def render_html(path_to_html, width=590, height=750, as_xhtml=True): def check_ebook_format(stream, current_guess): ans = current_guess - if current_guess.lower() in ('prc', 'mobi', 'azw', 'azw1'): + if current_guess.lower() in ('prc', 'mobi', 'azw', 'azw1', 'azw3'): stream.seek(0) if stream.read(3) == 'TPZ': ans = 'tpz' diff --git a/src/calibre/ebooks/metadata/archive.py b/src/calibre/ebooks/metadata/archive.py index b9136e5a13..e28389d7f7 100644 --- a/src/calibre/ebooks/metadata/archive.py +++ b/src/calibre/ebooks/metadata/archive.py @@ -70,7 +70,7 @@ class ArchiveExtract(FileTypePlugin): fname = fnames[0] ext = os.path.splitext(fname)[1][1:] if ext.lower() not in ('lit', 'epub', 'mobi', 'prc', 'rtf', 'pdf', - 'mp3', 'pdb', 'azw', 'azw1', 'fb2'): + 'mp3', 'pdb', 'azw', 'azw1', 'azw3', 'fb2'): return archive of = self.temporary_file('_archive_extract.'+ext) diff --git a/src/calibre/ebooks/metadata/meta.py b/src/calibre/ebooks/metadata/meta.py index 61afe3c49c..83d109fcef 100644 --- a/src/calibre/ebooks/metadata/meta.py +++ b/src/calibre/ebooks/metadata/meta.py @@ -15,7 +15,7 @@ _METADATA_PRIORITIES = [ 'html', 'htm', 'xhtml', 'xhtm', 'rtf', 'fb2', 'pdf', 'prc', 'odt', 'epub', 'lit', 'lrx', 'lrf', 'mobi', - 'rb', 'imp', 'azw', 'snb' + 'rb', 'imp', 'azw', 'azw3', 'azw1' 'snb' ] # The priorities for loading metadata from different file types @@ -85,7 +85,7 @@ def _get_metadata(stream, stream_type, use_libprs_metadata, if stream_type: stream_type = stream_type.lower() if stream_type in ('html', 'html', 'xhtml', 'xhtm', 'xml'): stream_type = 'html' - if stream_type in ('mobi', 'prc', 'azw'): + if stream_type in ('mobi', 'prc', 'azw', 'azw1', 'azw3'): stream_type = 'mobi' if stream_type in ('odt', 'ods', 'odp', 'odg', 'odf'): stream_type = 'odt' diff --git a/src/calibre/ebooks/metadata/mobi.py b/src/calibre/ebooks/metadata/mobi.py index 846015f491..e701946c01 100644 --- a/src/calibre/ebooks/metadata/mobi.py +++ b/src/calibre/ebooks/metadata/mobi.py @@ -341,11 +341,14 @@ class MetadataUpdater(object): kindle_pdoc = None share_not_sync = False if mi.author_sort and pas: - authors = mi.author_sort - update_exth_record((100, normalize(authors).encode(self.codec, 'replace'))) + # We want an EXTH field per author... + authors = mi.author_sort.split(' & ') + for author in authors: + update_exth_record((100, normalize(author).encode(self.codec, 'replace'))) elif mi.authors: - authors = ';'.join(mi.authors) - update_exth_record((100, normalize(authors).encode(self.codec, 'replace'))) + authors = mi.authors + for author in authors: + update_exth_record((100, normalize(author).encode(self.codec, 'replace'))) if mi.publisher: update_exth_record((101, normalize(mi.publisher).encode(self.codec, 'replace'))) if mi.comments: @@ -360,6 +363,7 @@ class MetadataUpdater(object): if mi.isbn: update_exth_record((104, mi.isbn.encode(self.codec, 'replace'))) if mi.tags: + # FIXME: Keep a single subject per EXTH field? subjects = '; '.join(mi.tags) update_exth_record((105, normalize(subjects).encode(self.codec, 'replace'))) diff --git a/src/calibre/ebooks/metadata/rar.py b/src/calibre/ebooks/metadata/rar.py index a9b5d45546..58ca283a1a 100644 --- a/src/calibre/ebooks/metadata/rar.py +++ b/src/calibre/ebooks/metadata/rar.py @@ -32,7 +32,7 @@ def get_metadata(stream): if stream_type: stream_type = stream_type[1:] if stream_type in ('lit', 'opf', 'prc', 'mobi', 'fb2', 'epub', - 'rb', 'imp', 'pdf', 'lrf', 'azw'): + 'rb', 'imp', 'pdf', 'lrf', 'azw', 'azw1', 'azw3'): with TemporaryDirectory() as tdir: with CurrentDir(tdir): stream = extract_member(path, match=None, name=f, diff --git a/src/calibre/ebooks/metadata/zip.py b/src/calibre/ebooks/metadata/zip.py index 887975b993..7369d2055c 100644 --- a/src/calibre/ebooks/metadata/zip.py +++ b/src/calibre/ebooks/metadata/zip.py @@ -23,7 +23,7 @@ def get_metadata(stream): if stream_type: stream_type = stream_type[1:] if stream_type in ('lit', 'opf', 'prc', 'mobi', 'fb2', 'epub', - 'rb', 'imp', 'pdf', 'lrf', 'azw'): + 'rb', 'imp', 'pdf', 'lrf', 'azw', 'azw1', 'azw3'): with TemporaryDirectory() as tdir: with CurrentDir(tdir): path = zf.extract(f) diff --git a/src/calibre/ebooks/mobi/writer8/exth.py b/src/calibre/ebooks/mobi/writer8/exth.py index 508b77ce5b..fa0da0d2ee 100644 --- a/src/calibre/ebooks/mobi/writer8/exth.py +++ b/src/calibre/ebooks/mobi/writer8/exth.py @@ -54,8 +54,16 @@ def build_exth(metadata, prefer_author_sort=False, is_periodical=False, items = metadata[term] if term == 'creator': if prefer_author_sort: - creators = [unicode(c.file_as or c) for c in + # This is a bit hackish... We only get the first item in the creators list, + # because we only care about the file_as property, and it contains *all* the authors in every creator markup, + # so we only need one, or we end up with duplicates ;). + # We then end up with a single item in our list, that contains every authors, in author sort syntax, separated by an ' & ' character. + # That's not good enough, because we want each author in a separate entry in the list, so we just split this on every & ;). + # This way, we properly end up with multiple Creator fields in the EXTH header, one for each author, like KindleGen :). + all_creators = [unicode(c.file_as or c) for c in items][:1] + for creator in all_creators: + creators = creator.split(' & ') else: creators = [unicode(c) for c in items] items = creators diff --git a/src/calibre/gui2/actions/add.py b/src/calibre/gui2/actions/add.py index ef7ed7a594..4f3e9fc066 100644 --- a/src/calibre/gui2/actions/add.py +++ b/src/calibre/gui2/actions/add.py @@ -30,7 +30,7 @@ def get_filters(): (_('LRF Books'), ['lrf']), (_('HTML Books'), ['htm', 'html', 'xhtm', 'xhtml']), (_('LIT Books'), ['lit']), - (_('MOBI Books'), ['mobi', 'prc', 'azw']), + (_('MOBI Books'), ['mobi', 'prc', 'azw', 'azw3']), (_('Topaz books'), ['tpz','azw1']), (_('Text books'), ['txt', 'text', 'rtf']), (_('PDF Books'), ['pdf', 'azw4']), diff --git a/src/calibre/gui2/wizard/__init__.py b/src/calibre/gui2/wizard/__init__.py index d831307d9a..569c72ae55 100644 --- a/src/calibre/gui2/wizard/__init__.py +++ b/src/calibre/gui2/wizard/__init__.py @@ -446,7 +446,7 @@ class KindlePage(QWizardPage, KindleUI): if not accounts: accounts = {} for y in accounts.values(): y[2] = False - accounts[x] = ['AZW, MOBI, TPZ, PRC, AZW1', True, True] + accounts[x] = ['AZW, MOBI, TPZ, PRC, AZW1, AZW3', True, True] conf.set('accounts', accounts) def nextId(self): From 8eb97bbe83232e0591f93b21b311f22be3fbbdd2 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Fri, 14 Sep 2012 18:01:18 +0200 Subject: [PATCH 14/41] Never build an AZW3 periodical, even if it's the preferred output format (FIXME: this should ideally handle mobi both & mobi new formats, too) --- src/calibre/gui2/tools.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/calibre/gui2/tools.py b/src/calibre/gui2/tools.py index 36c1a6f30f..b3375ad842 100644 --- a/src/calibre/gui2/tools.py +++ b/src/calibre/gui2/tools.py @@ -234,6 +234,9 @@ class QueueBulk(QProgressDialog): def fetch_scheduled_recipe(arg): # {{{ fmt = prefs['output_format'].lower() + # Never use AZW3 for periodicals... + if fmt == 'azw3': + fmt = 'mobi' pt = PersistentTemporaryFile(suffix='_recipe_out.%s'%fmt.lower()) pt.close() recs = [] From 7690d8a97dbaf2ef3860dcb23a5d1696442412f3 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Fri, 14 Sep 2012 18:02:50 +0200 Subject: [PATCH 15/41] Set the KF8 thumbnail URI (EXTH 129) in a similar manner as KindleGen 2.5 --- src/calibre/ebooks/mobi/writer8/exth.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/mobi/writer8/exth.py b/src/calibre/ebooks/mobi/writer8/exth.py index 508b77ce5b..9362a07d81 100644 --- a/src/calibre/ebooks/mobi/writer8/exth.py +++ b/src/calibre/ebooks/mobi/writer8/exth.py @@ -11,7 +11,7 @@ import re from struct import pack from io import BytesIO -from calibre.ebooks.mobi.utils import utf8_text +from calibre.ebooks.mobi.utils import (utf8_text, to_base) from calibre.utils.localization import lang_as_iso639_1 EXTH_CODES = { @@ -30,6 +30,7 @@ EXTH_CODES = { 'startreading': 116, 'kf8_header_index': 121, 'num_of_resources': 125, + 'kf8_thumbnail_uri': 129, 'kf8_unknown_count': 131, 'coveroffset': 201, 'thumboffset': 202, @@ -159,7 +160,10 @@ def build_exth(metadata, prefer_author_sort=False, is_periodical=False, if thumbnail_offset is not None: exth.write(pack(b'>III', EXTH_CODES['thumboffset'], 12, thumbnail_offset)) - nrecs += 1 + thumbnail_uri_str = bytes('kindle:embed:%s' %(to_base(thumbnail_offset, base=32, min_num_digits=4))) + exth.write(pack(b'>II', EXTH_CODES['kf8_thumbnail_uri'], len(thumbnail_uri_str) + 8)) + exth.write(thumbnail_uri_str) + nrecs += 2 if start_offset is not None: try: From 6e93e8fada9735a838f0b16c81536a91563f54f2 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Fri, 14 Sep 2012 18:04:44 +0200 Subject: [PATCH 16/41] Add an icon for AZW3, AZW2 & TOPAZ file formats. Use the same mimetypes as Amazon (on the Kindle Touch) for a bunch of Amazon formats Tweak the xdg mimetypes xml file to actually be taken into account (apparently really needs to be a .xml) --- imgsrc/mimetypes/azw2.svg | 237 +++++ imgsrc/mimetypes/azw3.svg | 237 +++++ imgsrc/mimetypes/mobi.svg | 42 +- imgsrc/mimetypes/tpz.svg | 237 +++++ resources/images/mimetypes/azw2.png | Bin 0 -> 8343 bytes resources/images/mimetypes/azw3.png | Bin 0 -> 7815 bytes resources/images/mimetypes/mobi.png | Bin 7489 -> 7992 bytes resources/images/mimetypes/tpz.png | Bin 0 -> 8372 bytes resources/mime.types | 1207 ++++++++++++----------- src/calibre/gui2/__init__.py | 7 +- src/calibre/gui2/convert/azw3_output.py | 2 +- src/calibre/linux.py | 45 +- 12 files changed, 1399 insertions(+), 615 deletions(-) create mode 100644 imgsrc/mimetypes/azw2.svg create mode 100644 imgsrc/mimetypes/azw3.svg create mode 100644 imgsrc/mimetypes/tpz.svg create mode 100644 resources/images/mimetypes/azw2.png create mode 100644 resources/images/mimetypes/azw3.png create mode 100644 resources/images/mimetypes/tpz.png diff --git a/imgsrc/mimetypes/azw2.svg b/imgsrc/mimetypes/azw2.svg new file mode 100644 index 0000000000..1c3c718b0b --- /dev/null +++ b/imgsrc/mimetypes/azw2.svg @@ -0,0 +1,237 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + Kindlet + + + + + diff --git a/imgsrc/mimetypes/azw3.svg b/imgsrc/mimetypes/azw3.svg new file mode 100644 index 0000000000..c60a7070f9 --- /dev/null +++ b/imgsrc/mimetypes/azw3.svg @@ -0,0 +1,237 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + KF8 + + + + + diff --git a/imgsrc/mimetypes/mobi.svg b/imgsrc/mimetypes/mobi.svg index 970456b0cb..9089dac15c 100644 --- a/imgsrc/mimetypes/mobi.svg +++ b/imgsrc/mimetypes/mobi.svg @@ -8,10 +8,37 @@ xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" version="1.0" width="128" height="128" - id="svg2606"> + id="svg2606" + inkscape:version="0.48.3.1 r9886" + sodipodi:docname="mobi.svg" + inkscape:export-filename="/home/niluje/Patchland/calibre/imgsrc/mimetypes/mobi.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90"> + mobi + style="font-size:28px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;font-family:DejaVu Sans;-inkscape-font-specification:DejaVu Sans">mobi + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + Topaz + + + + + diff --git a/resources/images/mimetypes/azw2.png b/resources/images/mimetypes/azw2.png new file mode 100644 index 0000000000000000000000000000000000000000..229d98ed3878a0516fc48d851b6850ea974d1c4d GIT binary patch literal 8343 zcmWk!1zZ$O6u+Yc2|>C;5Rek-I*yR;5RjJ6LpqKFq#G3Jl9WTbJ0&CzX{DvR&@8|wcKv|9~Uvwe0=UYQhU5KrxkEOc}z{kgj*TL1v!^+alh8N;) zmvtmb0{}1ql;vgge6tU8{IbbrTCTfF1Kv?YQd+shQxIe<3bx zIdv?MiN|H_j8+)+>f3N^*LG{+h3dIIVU;gv4*t$TW6M;4i_!bKPq_EBD&j&%fBT`Z zwYB{JGXNe*&DVw4hPLiGd%JV>TIl zMe?r==L4(lD>7<_U=Cz7FafuB?UUex3iv7Wo97sF7#1uml!UOU8Y8NNd=HDH%D178 zbapIQ8TNossC3dZGWnqMD10CtNtj9B;=T|V$O0C zh24*b$aFpp3uc;#c)ai1DFHYC#&E#y-ngKqVPed=FAQGZk<|+3#Zu^eF+@+GqwiT8 z3XbK}VEz?C%k1Wa@mvVZFOCc>N~yA$ynS&(AsdBX5J}?cLi~~!i+&EUsTs2R-=f|lRMS6)*-teE5v|KSC=xD~9Gw!o-0j&5TjBe^M z+YXQs{?4VJYC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EGYm1a6kt;lE^ui;PHN?f0R2ef>1@GxPd+asofGV4+M z@zFKysAQWf=J^Y5IwI0&dECestpFt+UR*dYSqz*-NZH7Ua})E)|4}GQveJ)s5;UN# z_P#p!qdI{nEpGxKxMTDHEM38New0~|5;ff-tnD=63=qoFYx{654tZl^S{D}=tWX)* zZ%NSy%?=zqJT^l$gYKiRpL`LTtkSl30?dr=H_03ZQ@!*p z@18V9XC%X~+sHBM#uDXO(Dh)10MJY#I-Y~dqGMdmL zH8HZP^)_kadOf{(?HiJXdKx_&4uLI*)T4FO2~pX{%uZ>4Mvi> zPIu|@`G^Z=0puRCf>c%S`u7aYB1Gho1rgT63C$%EEC@_TZZ{7~e4rD5j z=!v#36{XgUO0I&_z~OJ{!Qr)U9*PY_q`FEJS|-1K z+`FtCN;|b#Xx^LKz9!c{euyb>JE$2fIlTO)6@_MqJ}ix*rD?^sBKdp0Y)rG?QV1C7 zfju!+SI?FwADMhZ*99+-XZa2vSnUa&`fRSNTj&3`-oZm(U#L8=tp+wrDz%$r4BYuw z(i8undA(RX?Wvm&muGpJ93|Uz2D^cFrZ@(n7Zyg))bC>o93C00@Na`%<8&(yDoPM5 zV@jP7_w*u{5v4CgsIRN7A8v(1+f2MO=x83!(1BP3(2voG^ zkfXcAdYW>g0B$Z5Eq`)%zB5&t=u!oNKny6j4Nv;fe9kHG)H3(a!m-}j8f_8KoztQW zi=~q&U-K~~?Yi#AHf=snL})kL-n|-yu7?)wkz;humk}2NA(=Ck@DDq-TQ(6q| z2lNfoJjSe`BdXbvSj66*M2+h9s&6x*1 z95gu1!NME1o1UAGG^w3cozdYkr19KM=gFHV!?BpfzMLlj=vZ1oLu_iB^ zC@`#iDYF*8(I!31kO;}#MKf18$QA2N5pVF364y#SIVD8{(e W@R6?h=(p%Hfbv@n`AS)fPyYdB%Xkq0 literal 0 HcmV?d00001 diff --git a/resources/images/mimetypes/azw3.png b/resources/images/mimetypes/azw3.png new file mode 100644 index 0000000000000000000000000000000000000000..04e913b288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zDO5x_e(GEuj;zOBe+1J=Ov9E|3<4{Uav8;JM=6E3Cx5LuzJjX^MUs(1UoE)dxg9V6 zNmZF!IMhJQ508(>Ct}@?MvrEQrD1V9$46mWs(O8FXfdc#x`;PSG;ZkDH^L(UXzklh zmDd@Bx$%DDvmVkP)cL@j4`~5d2YgZjXNx=sfoE=A;&Zl{E&9X-i#nUBc`X95`X^1u zwCQK);-0A$o6YX-+Lo7xn|+P(DL5ex;lzKE0FW1#kRT{~ zlXpK$ZxL`RRGW!V^?a^m3oWZpq^uwT$)h+=SOE6pAgtllfN z>)0*WU#i1W@q4$?g#J140qi9Z0{;+}e4I$n5JH<76q&# zyklI!Dc}VS2LPUC7Jl)T_Lr9}&XnMlb>*!H4r++pA>1vUA!^-(g zm+Bmot=>u9tSta^q93rFA>NCv{A(~TH5;WBs0u>$BXXSn(5SnX0GbY+Z0hc$N6UVh zXRq_3-SjHv1^}r-hbmgf_L6t?nb;D(5p*>qk1O`2;dp|3woW^@#A=zdh4@*phsFRc MHC@$eWy{e20}>En0{{R3 literal 0 HcmV?d00001 diff --git a/resources/images/mimetypes/mobi.png b/resources/images/mimetypes/mobi.png index cb1230a15baf7b69fad77fe01a0fba92564107df..0446021706726da22d33881dbc8d31c83f75df48 100644 GIT binary patch literal 7992 zcmW+*1z1$w79C&^h8B=UT0l}j=`QK+lx`4dhVGIMX%Xq}Zb|9Rp&RKK^4NbDl1?V{#r;o|gs8el=1G=k68`Msi*Td27lBCsk1qsqk|-*M2!!|$RAqx zK_NNlfWM+iiEMlVa(EntcbAT&6&pjS5wdbH4kKfLDKdN9X#|;JZ?g*VSe|`uJgYR8 z48M{jM70`30ypeJF_ZSK4S$c2sSzySyKrbui4p8?yq)^F%^S_w>d8=j^IHIGJd7-F zZk-u!j}!xipn`mJiLc=(Dh2^gCddiz{eMmu>VPQT!&d{oDJN5sYCyP}YX`}=RO!@f zoE&j*azio##u|F^_8CdQ~-6ww3z*JD5tT zQnd!Z&52@}XqkSVm-f4b{J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1Tf;Aog3T$t?ZO2HYzHGZSDII%VjA*{dwuFX8!*_dClPxWR|EpR(|Eu;puz zLPk?cU!UTG!d#wrkv!d6mWBR{n;%o6P_Z-Dxk+r6N8gx*hOI9;=A-7De+TUo8dbUb zr@|R>UIK88)7ZW~{TlK^3|MlHdZQLj*K1;G+U$ZxPr1d~*Ms;*VQWX)a2lPXNI(F9 zX@Uls-D5A$RY3hbsbwLb8{7t^nMJ+R&s13MZJ1VHBi6AD-@a2i?EqKw2kQ?XOKgO> z2@-}Y8vt3^<)&>PtPR^^4F6yo70G-p3I3C<`tXwy zi?9NUDol_hOVQVHj3a)+8E7=Wpdc;L|9_JrAF=#rhS&)i10>ORq5usQ9p!38>&X8B DJkFbv diff --git a/resources/images/mimetypes/tpz.png b/resources/images/mimetypes/tpz.png new file mode 100644 index 0000000000000000000000000000000000000000..04d685fd2d9f963b4d7dc9d055a23eab365adbae GIT binary patch literal 8372 zcmW++1zb~K8y+xV^yuzXP`ad3LP}8NPYVc$boc0%2I&p~nbO?~l7ckSgGr8tk>B;Z zzun#6cF)f4J?DAe_j#XlV|2Bj6XDb0gFql6bv5Oez!COuhu{G3{j!!Lzya*8sBQoO zwg8BAH1HYEMa{?^Xg~LF$57qQJt_N3 zEmJ9{l#!bq{L>DU5FoyWA*6Ie*ry2M#%5g>xbUNehOj^(2Y6*t+@Q!6lq#nz{a><0 zThdt^?w`)gb_h)v^AX0NZtw%B>JfC`E+ib&!sS|oXib5$Tk03lD~OO@ggmb|*-n^h zRk%hIiJe$!Ot{2XcCeS0d;`u9&?>5!hnf5Lb*c+hD2oa8Gs5EcVIWIZyLKFbmAJ1Y zg?I{vurOSb_0t|(W*>6acM|;$X+iZK`j+>-yO}jFd1f3BeQL6-&8OsK1*goX zg>GxyH4&*o-+$u6ve@ldEb{O^^^Q>J$ zEnv8`S%tR&Lwjx~2`AbX)8g;f-+YXn`}_MYtwl=5KGL%s#-zD8O9h1Mc^>mQe(TsySLz{X!UcDW*jxtoY?hiF_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kZDe?4+ zCb`JqmoLE5)gQl+C(Wa^pFi8Pyyy}vN3rkkdrF*yly*_>$ZE`w%uni3VB2jMl&H5beBRldxRdCcOnK@h?PVq0I`pjkie z6f9q5mA>;);{nAM^RPZCl<|R{D<}m1;xjlg&Amc|wbGtNG(~@X%9tDQ)e`e8G;~do zb0Oh+=W6tqY?#`Kjy0<;p??X~u3t)~MTwh*ImH{(rvKYJEK%UpMv0|IbfXsP{MT`= z4Db9b2)YiX6Tj+K>B1=y`_(+I*bx~#$1w#wFu?imS%6Y7$buF2@ub>+ npclM5e_6Xk3hT+35*|q0-6r&;y9~*JAArSONY E-book source format + + Amazon Mobipocket e-book format + + + + + Amazon Topaz ebook format + + + + + Amazon Kindle Application (Kindlet) + + + + + Amazon Mobipocket ebook newspaper format + + + + + + + Amazon KF8 ebook format + + + ''' From 8f62e20b9c07f90bf0140475ed62743b9d09763a Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Fri, 14 Sep 2012 18:08:37 +0200 Subject: [PATCH 17/41] Use the extended APNX content header for KF8 files, FW 3.4 seems to discard the file when the older format is used with a KF8 file... --- src/calibre/devices/kindle/apnx.py | 49 ++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/src/calibre/devices/kindle/apnx.py b/src/calibre/devices/kindle/apnx.py index 4336df81a6..f279efe5a4 100644 --- a/src/calibre/devices/kindle/apnx.py +++ b/src/calibre/devices/kindle/apnx.py @@ -12,7 +12,10 @@ import struct from calibre.ebooks.mobi.reader.mobi6 import MobiReader from calibre.ebooks.pdb.header import PdbHeaderReader +from calibre.ebooks.mobi.reader.headers import MetadataHeader from calibre.utils.logging import default_log +from calibre import prints +from calibre.constants import DEBUG class APNXBuilder(object): ''' @@ -25,12 +28,31 @@ class APNXBuilder(object): pass in a value to page_count, otherwise a count will be estimated using either the fast or accurate algorithm. ''' + import uuid # Check that this is really a MOBI file. with open(mobi_file_path, 'rb') as mf: ident = PdbHeaderReader(mf).identity() if ident != 'BOOKMOBI': raise Exception(_('Not a valid MOBI file. Reports identity of %s') % ident) + # We'll need the PDB name, the MOBI version, and some metadata to make FW 3.4 happy with KF8 files... + apnx_meta = { 'guid': str(uuid.uuid4()).replace('-', '')[:8], 'asin': '', 'cdetype': 'EBOK', 'format': 'MOBI_7', 'acr': '' } + with open(mobi_file_path, 'rb') as mf: + apnx_meta['acr'] = str(PdbHeaderReader(mf).name()) + mh = MetadataHeader(mf, default_log) + if mh.mobi_version == 8: + apnx_meta['format'] = 'MOBI_8' + else: + apnx_meta['format'] = 'MOBI_7' + if mh.exth is None or not mh.exth.cdetype: + apnx_meta['cdetype'] = 'EBOK' + else: + apnx_meta['cdetype'] = str(mh.exth.cdetype) + if mh.exth is None or not mh.exth.uuid: + apnx_meta['asin'] = '' + else: + apnx_meta['asin'] = str(mh.exth.uuid) + # Get the pages depending on the chosen parser pages = [] if page_count: @@ -51,23 +73,32 @@ class APNXBuilder(object): raise Exception(_('Could not generate page mapping.')) # Generate the APNX file from the page mapping. - apnx = self.generate_apnx(pages) + apnx = self.generate_apnx(pages, apnx_meta) # Write the APNX. with open(apnx_path, 'wb') as apnxf: apnxf.write(apnx) - def generate_apnx(self, pages): - import uuid + def generate_apnx(self, pages, apnx_meta): apnx = '' - content_vals = { - 'guid': str(uuid.uuid4()).replace('-', '')[:8], - 'isbn': '', - } + if DEBUG: + prints('APNX META: guid:', apnx_meta['guid']) + prints('APNX META: ASIN:', apnx_meta['asin']) + prints('APNX META: CDE:', apnx_meta['cdetype']) + prints('APNX META: format:', apnx_meta['format']) + prints('APNX META: Name:', apnx_meta['acr']) - content_header = '{"contentGuid":"%(guid)s","asin":"%(isbn)s","cdeType":"EBOK","fileRevisionId":"1"}' % content_vals - page_header = '{"asin":"%(isbn)s","pageMap":"(1,a,1)"}' % content_vals + # Updated header if we have a KF8 file... + if apnx_meta['format'] == 'MOBI_8': + content_header = '{"contentGuid":"%(guid)s","asin":"%(asin)s","cdeType":"%(cdetype)s","format":"%(format)s","fileRevisionId":"1","acr":"%(acr)s"}' % apnx_meta + else: + # My 5.1.x Touch & 3.4 K3 seem to handle the 'extended' header fine for legacy mobi files, too. But, since they still handle this one too, let's try not to break old devices, and keep using the simple header ;). + content_header = '{"contentGuid":"%(guid)s","asin":"%(asin)s","cdeType":"%(cdetype)s","fileRevisionId":"1"}' % apnx_meta + page_header = '{"asin":"%(asin)s","pageMap":"(1,a,1)"}' % apnx_meta + + if DEBUG: + prints('APNX Content Header:', content_header) apnx += struct.pack('>I', 65537) apnx += struct.pack('>I', 12 + len(content_header)) From 6b59c4214faa6bcf8ba57d68c26e6d03c5d1eb33 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 14 Sep 2012 21:52:33 +0530 Subject: [PATCH 18/41] Update LiveMint --- recipes/livemint.recipe | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/recipes/livemint.recipe b/recipes/livemint.recipe index 12f7b5c470..ef232ae519 100644 --- a/recipes/livemint.recipe +++ b/recipes/livemint.recipe @@ -7,20 +7,29 @@ class LiveMint(BasicNewsRecipe): #encoding = 'cp1252' oldest_article = 1 #days max_articles_per_feed = 25 - use_embedded_content = True + use_embedded_content = False no_stylesheets = True auto_cleanup = True feeds = [ -('Latest News', - 'http://www.livemint.com/StoryRss.aspx?LN=Latestnews'), - ('Gallery', - 'http://www.livemint.com/GalleryRssfeed.aspx'), +('Companies', + 'http://www.livemint.com/rss/companies'), + ('Consumer', + 'http://www.livemint.com/rss/consumer'), ('Top Stories', - 'http://www.livemint.com/StoryRss.aspx?ts=Topstories'), - ('Banking', - 'http://www.livemint.com/StoryRss.aspx?Id=104'), + 'http://www.livemint.com/rss/homepage'), + ('Opinion', + 'http://www.livemint.com/rss/opinion'), + ('Money', + 'http://www.livemint.com/rss/money'), + ('Industry', + 'http://www.livemint.com/rss/industry'), + ('Economy Politics', + 'http://www.livemint.com/rss/economy_politics'), + ('Lounge', + 'http://www.livemint.com/rss/lounge'), ] + From e669ffd8eccedb80f444e124ad97a3b08aa46c5a Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Fri, 14 Sep 2012 18:49:13 +0200 Subject: [PATCH 19/41] Nope, Amazon still doesn't allow sending AZW3 over email, my bad. --- src/calibre/gui2/wizard/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/gui2/wizard/__init__.py b/src/calibre/gui2/wizard/__init__.py index 569c72ae55..d831307d9a 100644 --- a/src/calibre/gui2/wizard/__init__.py +++ b/src/calibre/gui2/wizard/__init__.py @@ -446,7 +446,7 @@ class KindlePage(QWizardPage, KindleUI): if not accounts: accounts = {} for y in accounts.values(): y[2] = False - accounts[x] = ['AZW, MOBI, TPZ, PRC, AZW1, AZW3', True, True] + accounts[x] = ['AZW, MOBI, TPZ, PRC, AZW1', True, True] conf.set('accounts', accounts) def nextId(self): From 4ef340cb208508eb699b567c35d9ce29b1c6e1c9 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 14 Sep 2012 22:19:44 +0530 Subject: [PATCH 20/41] Driver for HTC Flyer --- src/calibre/devices/android/driver.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/calibre/devices/android/driver.py b/src/calibre/devices/android/driver.py index 77846a1b5f..18b2ab31e9 100644 --- a/src/calibre/devices/android/driver.py +++ b/src/calibre/devices/android/driver.py @@ -45,6 +45,7 @@ class ANDROID(USBMS): 0xce5 : HTC_BCDS, 0xcec : HTC_BCDS, 0x2910 : HTC_BCDS, + 0xe77 : HTC_BCDS, 0xff9 : HTC_BCDS, }, From 11e670e61e2edbd4bdc243c92eecce1430165fa5 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Fri, 14 Sep 2012 20:50:54 +0200 Subject: [PATCH 21/41] Document the content header changes for the whole APNX/KF8 thing on FW 3.4 --- format_docs/pdb/apnx.txt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/format_docs/pdb/apnx.txt b/format_docs/pdb/apnx.txt index f9feed1da1..8fcba3f029 100644 --- a/format_docs/pdb/apnx.txt +++ b/format_docs/pdb/apnx.txt @@ -9,7 +9,7 @@ the file are big-endian. Layout ------ -bytes content comments +bytes content comments 4 00010001 Format identifier. Value of 65537 little-endian. 4 start of next The offset after ending location of the first header. @@ -25,7 +25,7 @@ Starts next sequence 2 unknown Always 32 N second header String containing the page mapping header 4*N padding The first number given in the page mapping header indicates the number of 0 bytes. -4*N page list +4*N page list Content Header @@ -44,6 +44,14 @@ Example: {"contentGuid":"d8c14b0","asin":"B000JML5VM","cdeType":"EBOK","fileRevisionId":"1296874359405"} +In devices with KF8 support, we're seeing an extended content header (which seems to be required by some FW versions for KF8 files, like FW 3.4): + +format Mobi version. MOBI_8 for KF8, MOBI_7 for legacy mobi files. +acr Palm DB name + +Example: +{"contentGuid":"f2fc7597","asin":"B003M68YKM","cdeType":"EBOK","format":"MOBI_8","fileRevisionId":"1342776186889","acr":"CR!1F5WDHWWVN4Y78MA87Z13H9K6RKE"} + Page Mapping Header ------------------- From 7def8f0b643cf5f586bfa6427665e1f8f9c7cd0e Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Fri, 14 Sep 2012 20:55:02 +0200 Subject: [PATCH 22/41] Delete .han files on Kindle 2/3/Touch, too (linked to KF8 files) --- src/calibre/devices/kindle/driver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/devices/kindle/driver.py b/src/calibre/devices/kindle/driver.py index ac3bcb4bc1..fc3672ccb8 100644 --- a/src/calibre/devices/kindle/driver.py +++ b/src/calibre/devices/kindle/driver.py @@ -289,7 +289,7 @@ class KINDLE2(KINDLE): description = _('Communicate with the Kindle 2/3/4/Touch eBook reader.') FORMATS = ['azw3'] + KINDLE.FORMATS + ['pdf', 'azw4', 'pobi'] - DELETE_EXTS = KINDLE.DELETE_EXTS + ['.mbp1', '.mbs', '.sdr'] + DELETE_EXTS = KINDLE.DELETE_EXTS + ['.mbp1', '.mbs', '.sdr', '.han'] PRODUCT_ID = [0x0002, 0x0004] BCD = [0x0100] From 4296f5c8dbc9bb609dd65e913f02f052d03ebfc7 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Fri, 14 Sep 2012 21:37:37 +0200 Subject: [PATCH 23/41] More comments on the sidecar folder/files with KF8 files --- src/calibre/devices/kindle/driver.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/calibre/devices/kindle/driver.py b/src/calibre/devices/kindle/driver.py index fc3672ccb8..a657b777f7 100644 --- a/src/calibre/devices/kindle/driver.py +++ b/src/calibre/devices/kindle/driver.py @@ -290,6 +290,7 @@ class KINDLE2(KINDLE): FORMATS = ['azw3'] + KINDLE.FORMATS + ['pdf', 'azw4', 'pobi'] DELETE_EXTS = KINDLE.DELETE_EXTS + ['.mbp1', '.mbs', '.sdr', '.han'] + # On the Touch, there's also .asc files, but not using the same basename (for X-Ray & End Actions), azw3f & azw3r files, but all of them are in the .sdr sidecar folder PRODUCT_ID = [0x0002, 0x0004] BCD = [0x0100] From b4e2dc54d14c43cce656822704b28cc96ed3aacf Mon Sep 17 00:00:00 2001 From: GRiker Date: Fri, 14 Sep 2012 13:50:48 -0600 Subject: [PATCH 24/41] Fix for AZW3 catalogs not properly navigating index points --- src/calibre/library/catalogs/epub_mobi.py | 7 +- .../library/catalogs/epub_mobi_builder.py | 90 +++++++++++-------- 2 files changed, 59 insertions(+), 38 deletions(-) diff --git a/src/calibre/library/catalogs/epub_mobi.py b/src/calibre/library/catalogs/epub_mobi.py index 668fb5156f..cea87ea2ce 100644 --- a/src/calibre/library/catalogs/epub_mobi.py +++ b/src/calibre/library/catalogs/epub_mobi.py @@ -360,13 +360,14 @@ class EPUB_MOBI(CatalogPlugin): recommendations.append(('debug_pipeline', dp, OptionRecommendation.HIGH)) - if opts.fmt == 'mobi' and opts.output_profile and opts.output_profile.startswith("kindle"): + if opts.output_profile and opts.output_profile.startswith("kindle"): recommendations.append(('output_profile', opts.output_profile, OptionRecommendation.HIGH)) - recommendations.append(('no_inline_toc', True, - OptionRecommendation.HIGH)) recommendations.append(('book_producer',opts.output_profile, OptionRecommendation.HIGH)) + if opts.fmt == 'mobi': + recommendations.append(('no_inline_toc', True, + OptionRecommendation.HIGH)) # Use existing cover or generate new cover cpath = None diff --git a/src/calibre/library/catalogs/epub_mobi_builder.py b/src/calibre/library/catalogs/epub_mobi_builder.py index ee7c603f0d..347c5792be 100644 --- a/src/calibre/library/catalogs/epub_mobi_builder.py +++ b/src/calibre/library/catalogs/epub_mobi_builder.py @@ -460,8 +460,9 @@ class CatalogBuilder(object): catalog_resources = P("catalog") files_to_copy = [('','DefaultCover.jpg'), - ('content','stylesheet.css'), - ('images','mastheadImage.gif')] + ('content','stylesheet.css')] + if self.generate_for_kindle_mobi: + files_to_copy.extend([('images','mastheadImage.gif')]) for file in files_to_copy: if file[0] == '': @@ -2781,7 +2782,8 @@ class CatalogBuilder(object): ncx = soup.find('ncx') navMapTag = Tag(soup, 'navMap') navPointTag = Tag(soup, 'navPoint') - navPointTag['class'] = "periodical" + if self.generate_for_kindle_mobi: + navPointTag['class'] = "periodical" navPointTag['id'] = "title" navPointTag['playOrder'] = self.play_order self.play_order += 1 @@ -2820,12 +2822,13 @@ class CatalogBuilder(object): contentTag['src'] = "content/book_%d.html" % int(sort_descriptions_by[0]['id']) navPointTag.insert(1, contentTag) - cmiTag = Tag(soup, '%s' % 'calibre:meta-img') - cmiTag['id'] = "mastheadImage" - cmiTag['src'] = "images/mastheadImage.gif" - navPointTag.insert(2,cmiTag) - navMapTag.insert(0,navPointTag) + if self.generate_for_kindle_mobi: + cmiTag = Tag(soup, '%s' % 'calibre:meta-img') + cmiTag['id'] = "mastheadImage" + cmiTag['src'] = "images/mastheadImage.gif" + navPointTag.insert(2,cmiTag) + navMapTag.insert(0,navPointTag) ncx.insert(0,navMapTag) self.ncx_soup = soup @@ -2853,7 +2856,8 @@ class CatalogBuilder(object): # Add the section navPoint navPointTag = Tag(ncx_soup, 'navPoint') - navPointTag['class'] = "section" + if self.generate_for_kindle_mobi: + navPointTag['class'] = "section" navPointTag['id'] = "bytitle-ID" navPointTag['playOrder'] = self.play_order self.play_order += 1 @@ -2865,7 +2869,7 @@ class CatalogBuilder(object): navPointTag.insert(nptc, navLabelTag) nptc += 1 contentTag = Tag(ncx_soup,"content") - contentTag['src'] = "content/book_%d.html" % int(self.books_by_title[0]['id']) + contentTag['src'] = "content/book_%d.html" % int(self.books_by_author[0]['id']) navPointTag.insert(nptc, contentTag) nptc += 1 @@ -2875,7 +2879,8 @@ class CatalogBuilder(object): for book in sort_descriptions_by: navPointVolumeTag = Tag(ncx_soup, 'navPoint') - navPointVolumeTag['class'] = "article" + if self.generate_for_kindle_mobi: + navPointVolumeTag['class'] = "article" navPointVolumeTag['id'] = "book%dID" % int(book['id']) navPointVolumeTag['playOrder'] = self.play_order self.play_order += 1 @@ -2979,7 +2984,8 @@ class CatalogBuilder(object): # --- Construct the 'Books By Series' section --- navPointTag = Tag(soup, 'navPoint') - navPointTag['class'] = "section" + if self.generate_for_kindle_mobi: + navPointTag['class'] = "section" navPointTag['id'] = "byseries-ID" navPointTag['playOrder'] = self.play_order self.play_order += 1 @@ -3035,7 +3041,8 @@ class CatalogBuilder(object): # Add *article* entries for each populated series title letter for (i,books) in enumerate(series_by_letter): navPointByLetterTag = Tag(soup, 'navPoint') - navPointByLetterTag['class'] = "article" + if self.generate_for_kindle_mobi: + navPointByLetterTag['class'] = "article" navPointByLetterTag['id'] = "%sSeries-ID" % (title_letters[i].upper()) navPointTag['playOrder'] = self.play_order self.play_order += 1 @@ -3102,7 +3109,8 @@ class CatalogBuilder(object): # --- Construct the 'Books By Title' section --- navPointTag = Tag(soup, 'navPoint') - navPointTag['class'] = "section" + if self.generate_for_kindle_mobi: + navPointTag['class'] = "section" navPointTag['id'] = "byalphatitle-ID" navPointTag['playOrder'] = self.play_order self.play_order += 1 @@ -3160,7 +3168,8 @@ class CatalogBuilder(object): # Add *article* entries for each populated title letter for (i,books) in enumerate(books_by_letter): navPointByLetterTag = Tag(soup, 'navPoint') - navPointByLetterTag['class'] = "article" + if self.generate_for_kindle_mobi: + navPointByLetterTag['class'] = "article" navPointByLetterTag['id'] = "%sTitles-ID" % (title_letters[i].upper()) navPointTag['playOrder'] = self.play_order self.play_order += 1 @@ -3225,7 +3234,8 @@ class CatalogBuilder(object): # --- Construct the 'Books By Author' *section* --- navPointTag = Tag(soup, 'navPoint') - navPointTag['class'] = "section" + if self.generate_for_kindle_mobi: + navPointTag['class'] = "section" file_ID = "%s" % tocTitle.lower() file_ID = file_ID.replace(" ","") navPointTag['id'] = "%s-ID" % file_ID @@ -3275,7 +3285,8 @@ class CatalogBuilder(object): # master_author_list{}: [0]:author list [1]:Initial letter for authors_by_letter in master_author_list: navPointByLetterTag = Tag(soup, 'navPoint') - navPointByLetterTag['class'] = "article" + if self.generate_for_kindle_mobi: + navPointByLetterTag['class'] = "article" navPointByLetterTag['id'] = "%sauthors-ID" % (authors_by_letter[1]) navPointTag['playOrder'] = self.play_order self.play_order += 1 @@ -3346,7 +3357,8 @@ class CatalogBuilder(object): # --- Construct the 'Recently Added' *section* --- navPointTag = Tag(soup, 'navPoint') - navPointTag['class'] = "section" + if self.generate_for_kindle_mobi: + navPointTag['class'] = "section" file_ID = "%s" % tocTitle.lower() file_ID = file_ID.replace(" ","") navPointTag['id'] = "%s-ID" % file_ID @@ -3390,7 +3402,8 @@ class CatalogBuilder(object): # master_date_range_list{}: [0]:titles list [1]:datestr for books_by_date_range in master_date_range_list: navPointByDateRangeTag = Tag(soup, 'navPoint') - navPointByDateRangeTag['class'] = "article" + if self.generate_for_kindle_mobi: + navPointByDateRangeTag['class'] = "article" navPointByDateRangeTag['id'] = "%s-ID" % books_by_date_range[1].replace(' ','') navPointTag['playOrder'] = self.play_order self.play_order += 1 @@ -3449,7 +3462,8 @@ class CatalogBuilder(object): for books_by_month in master_month_list: datestr = strftime(u'%B %Y', books_by_month[1].timetuple()) navPointByMonthTag = Tag(soup, 'navPoint') - navPointByMonthTag['class'] = "article" + if self.generate_for_kindle_mobi: + navPointByMonthTag['class'] = "article" navPointByMonthTag['id'] = "bda_%s-%s-ID" % (books_by_month[1].year,books_by_month[1].month ) navPointTag['playOrder'] = self.play_order self.play_order += 1 @@ -3524,7 +3538,8 @@ class CatalogBuilder(object): # --- Construct the 'Recently Read' *section* --- navPointTag = Tag(soup, 'navPoint') - navPointTag['class'] = "section" + if self.generate_for_kindle_mobi: + navPointTag['class'] = "section" file_ID = "%s" % tocTitle.lower() file_ID = file_ID.replace(" ","") navPointTag['id'] = "%s-ID" % file_ID @@ -3594,7 +3609,8 @@ class CatalogBuilder(object): for books_by_day in master_day_list: datestr = strftime(u'%A, %B %d', books_by_day[1].timetuple()) navPointByDayTag = Tag(soup, 'navPoint') - navPointByDayTag['class'] = "article" + if self.generate_for_kindle_mobi: + navPointByDayTag['class'] = "article" navPointByDayTag['id'] = "bdr_%s-%s-%sID" % (books_by_day[1].year, books_by_day[1].month, books_by_day[1].day ) @@ -3662,7 +3678,8 @@ class CatalogBuilder(object): # --- Construct the 'Books By Genre' *section* --- navPointTag = Tag(ncx_soup, 'navPoint') - navPointTag['class'] = "section" + if self.generate_for_kindle_mobi: + navPointTag['class'] = "section" file_ID = "%s" % tocTitle.lower() file_ID = file_ID.replace(" ","") navPointTag['id'] = "%s-ID" % file_ID @@ -3684,7 +3701,8 @@ class CatalogBuilder(object): for genre in self.genres: # Add an article for each genre navPointVolumeTag = Tag(ncx_soup, 'navPoint') - navPointVolumeTag['class'] = "article" + if self.generate_for_kindle_mobi: + navPointVolumeTag['class'] = "article" navPointVolumeTag['id'] = "genre-%s-ID" % genre['tag'] navPointVolumeTag['playOrder'] = self.play_order self.play_order += 1 @@ -3823,12 +3841,13 @@ class CatalogBuilder(object): manifest.insert(mtc, itemTag) mtc += 1 - itemTag = Tag(soup, "item") - itemTag['id'] = 'mastheadimage-image' - itemTag['href'] = "images/mastheadImage.gif" - itemTag['media-type'] = 'image/gif' - manifest.insert(mtc, itemTag) - mtc += 1 + if self.generate_for_kindle_mobi: + itemTag = Tag(soup, "item") + itemTag['id'] = 'mastheadimage-image' + itemTag['href'] = "images/mastheadImage.gif" + itemTag['media-type'] = 'image/gif' + manifest.insert(mtc, itemTag) + mtc += 1 # Write the thumbnail images, descriptions to the manifest sort_descriptions_by = [] @@ -3914,11 +3933,12 @@ class CatalogBuilder(object): stc += 1 # Guide - referenceTag = Tag(soup, "reference") - referenceTag['type'] = 'masthead' - referenceTag['title'] = 'mastheadimage-image' - referenceTag['href'] = 'images/mastheadImage.gif' - guide.insert(0,referenceTag) + if self.generate_for_kindle_mobi: + referenceTag = Tag(soup, "reference") + referenceTag['type'] = 'masthead' + referenceTag['title'] = 'mastheadimage-image' + referenceTag['href'] = 'images/mastheadImage.gif' + guide.insert(0,referenceTag) # Write the OPF file outfile = open("%s/%s.opf" % (self.catalog_path, self.opts.basename), 'w') From d921e444a72bdcd3eee6f80adca09732abdba5ce Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 15 Sep 2012 10:15:57 +0530 Subject: [PATCH 25/41] Windows: Ignore drives A: and B: when scanning for the drives belonging to a device --- src/calibre/utils/windows/winutil.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/calibre/utils/windows/winutil.c b/src/calibre/utils/windows/winutil.c index 64c943ffa5..5e45564032 100644 --- a/src/calibre/utils/windows/winutil.c +++ b/src/calibre/utils/windows/winutil.c @@ -276,8 +276,10 @@ get_all_removable_disks(struct tagDrives *g_drives) for(nLoopIndex = 0; nLoopIndex < MAX_DRIVES; nLoopIndex++) { - // if a drive is present, - if(dwDriveMask & 1) + // if a drive is present (we ignore the A and B drives as they are + // always present (even if no actual floppy is present) and we dont + // care about floppies) + if(nLoopIndex > 1 && dwDriveMask & 1) { caDrive[0] = 'A' + nLoopIndex; From 1c3fceb6bb726e708870daf6583e5785ceb5d94f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 15 Sep 2012 10:44:49 +0530 Subject: [PATCH 26/41] Fix printing of wide strings to console in winutil --- src/calibre/utils/windows/winutil.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/calibre/utils/windows/winutil.c b/src/calibre/utils/windows/winutil.c index 5e45564032..6b23f47c6d 100644 --- a/src/calibre/utils/windows/winutil.c +++ b/src/calibre/utils/windows/winutil.c @@ -95,6 +95,25 @@ struct tagDrives WCHAR volume[BUFSIZE]; }; +static void console_out(LPCWSTR fmt, LPCWSTR arg) { + char *bfmt, *barg; + int sz; + + sz = WideCharToMultiByte(CP_UTF8, 0, fmt, -1, NULL, 0, NULL, NULL); + bfmt = (char*)calloc(sz+1, sizeof(char)); + WideCharToMultiByte(CP_UTF8, 0, fmt, -1, bfmt, sz, NULL, NULL); + + sz = WideCharToMultiByte(CP_UTF8, 0, arg, -1, NULL, 0, NULL, NULL); + barg = (char*)calloc(sz+1, sizeof(char)); + WideCharToMultiByte(CP_UTF8, 0, arg, -1, barg, sz, NULL, NULL); + + if (bfmt != NULL && barg != NULL) { + printf(bfmt, barg); + fflush(stdout); + free(bfmt); free(barg); + } +} + static PyObject * winutil_folder_path(PyObject *self, PyObject *args) { int res; DWORD dwFlags; @@ -581,7 +600,7 @@ get_device_ancestors(HDEVINFO hDevInfo, DWORD index, PyObject *candidates, BOOL // Get the device instance of parent. if (CM_Get_Parent(&parent, pos, 0) != CR_SUCCESS) break; if (CM_Get_Device_ID(parent, temp, BUFSIZE, 0) == CR_SUCCESS) { - if (ddebug) wprintf(L"device id: %s\n", temp); fflush(stdout); + if (ddebug) console_out(L"device id: %s\n", temp); devid = PyUnicode_FromWideChar(temp, wcslen(temp)); if (devid) { PyList_Append(candidates, devid); @@ -637,14 +656,14 @@ winutil_get_removable_drives(PyObject *self, PyObject *args) { interfaceDetailData->DevicePath[length] = L'\\'; interfaceDetailData->DevicePath[length+1] = 0; - if (ddebug) wprintf(L"Device path: %s\n", interfaceDetailData->DevicePath); fflush(stdout); + if (ddebug) console_out(L"Device path: %s\n", interfaceDetailData->DevicePath); // On Vista+ DevicePath contains the information we need. temp = PyUnicode_FromWideChar(interfaceDetailData->DevicePath, length); if (temp == NULL) return PyErr_NoMemory(); PyList_Append(candidates, temp); Py_DECREF(temp); if(GetVolumeNameForVolumeMountPointW(interfaceDetailData->DevicePath, volume, BUFSIZE)) { - if (ddebug) wprintf(L"Volume: %s\n", volume); fflush(stdout); + if (ddebug) console_out(L"Volume: %s\n", volume); for(j = 0; j < MAX_DRIVES; j++) { if(g_drives[j].letter != 0 && wcscmp(g_drives[j].volume, volume)==0) { From 70ee81c6789b2f1027508624e52a8ba289c142c2 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 15 Sep 2012 17:31:20 +0530 Subject: [PATCH 27/41] Stamgasten by drMerry. Fixes #1051225 (Stamgasten, a new recipe) --- recipes/icons/stamgasten.png | Bin 0 -> 639 bytes recipes/stamgasten.recipe | 16 ++++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 recipes/icons/stamgasten.png create mode 100644 recipes/stamgasten.recipe diff --git a/recipes/icons/stamgasten.png b/recipes/icons/stamgasten.png new file mode 100644 index 0000000000000000000000000000000000000000..d363506829add85000933282c0971cb9a647b661 GIT binary patch literal 639 zcmV-_0)YLAP)Px#AY({UO#lFTCIA3{ga82g0001h=l}q9FaQARU;qF* zm;eA5aGbhPJOBUz{YgYYR5*=|l3!?2VHn0g4sBvfypVx{&~2=|ksOpWY*-vJlO)Hk z^`bveT079igt}Qn1l>Ym!wX?`7u!`)Nf#mP3?>mCXmsczD8a0tvAyc7kuV|NF)Nk-`~5sv9Y80(duCL{A_6$9yZ?F`~BTOE|)_f z5aIq7v5@NAfPhhcFP_Nhf1l4L4CX;FRkM{SVC<;_ng~Q>1 z)oSfhEEaWJ1cSkTfh^12WvA0YqtQUK*@UKPx`KQ@|Bv7|p?N%>r_pG%FbLG3K$%Zm Z@CP`MeaY$0O Date: Sat, 15 Sep 2012 18:40:19 +0530 Subject: [PATCH 28/41] Always return 0 from the GUI entry point in windows --- setup/installer/windows/main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/setup/installer/windows/main.c b/setup/installer/windows/main.c index 780be94330..56a022cb97 100644 --- a/setup/installer/windows/main.c +++ b/setup/installer/windows/main.c @@ -11,7 +11,6 @@ wWinMain(HINSTANCE Inst, HINSTANCE PrevInst, wchar_t *CmdLine, int CmdShow) { wchar_t *stdout_redirect, *stderr_redirect, basename[50]; - int ret = 0; set_gui_app((char)1); @@ -20,7 +19,7 @@ wWinMain(HINSTANCE Inst, HINSTANCE PrevInst, stdout_redirect = redirect_out_stream(basename, (char)1); stderr_redirect = redirect_out_stream(basename, (char)0); - ret = execute_python_entrypoint(BASENAME, MODULE, FUNCTION, + execute_python_entrypoint(BASENAME, MODULE, FUNCTION, stdout_redirect, stderr_redirect); if (stdout != NULL) fclose(stdout); @@ -29,7 +28,7 @@ wWinMain(HINSTANCE Inst, HINSTANCE PrevInst, DeleteFile(stdout_redirect); DeleteFile(stderr_redirect); - return ret; + return 0; // This should really be returning the value set in the WM_QUIT message, but I cannot be bothered figuring out how to get that. } #else From 4962c839fefcfa2e92aef1992ee2c532056e0c9f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 15 Sep 2012 23:18:03 +0530 Subject: [PATCH 29/41] ... --- src/calibre/devices/mtp/windows/driver.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/calibre/devices/mtp/windows/driver.py b/src/calibre/devices/mtp/windows/driver.py index 3f79e7d991..3da81d26e2 100644 --- a/src/calibre/devices/mtp/windows/driver.py +++ b/src/calibre/devices/mtp/windows/driver.py @@ -146,6 +146,13 @@ class MTP_DEVICE(MTPDeviceBase): p(traceback.format_exc()) return False + if not pnp_ids: + p('The Windows WPD service says there are no portable devices connected') + return False + + p('List of WPD PNP ids:') + p(pprint.pformat(list(pnp_ids))) + for pnp_id in pnp_ids: try: data = self.wpd.device_info(pnp_id) From 7787b9a206cbd41541fab4fbcace473d3d9027cf Mon Sep 17 00:00:00 2001 From: John Schember Date: Sat, 15 Sep 2012 21:10:57 -0400 Subject: [PATCH 30/41] Remove Beam Books due to lack of response to issues with the store. --- src/calibre/customize/builtins.py | 11 --- .../store/stores/beam_ebooks_de_plugin.py | 92 ------------------- 2 files changed, 103 deletions(-) delete mode 100644 src/calibre/gui2/store/stores/beam_ebooks_de_plugin.py diff --git a/src/calibre/customize/builtins.py b/src/calibre/customize/builtins.py index c7dc6a5b95..708e15ee78 100644 --- a/src/calibre/customize/builtins.py +++ b/src/calibre/customize/builtins.py @@ -1269,17 +1269,6 @@ class StoreBNStore(StoreBase): headquarters = 'US' formats = ['NOOK'] -class StoreBeamEBooksDEStore(StoreBase): - name = 'Beam EBooks DE' - author = 'Charles Haley' - description = u'Bei uns finden Sie: Tausende deutschsprachige eBooks; Alle eBooks ohne hartes DRM; PDF, ePub und Mobipocket Format; Sofortige Verfügbarkeit - 24 Stunden am Tag; Günstige Preise; eBooks für viele Lesegeräte, PC,Mac und Smartphones; Viele Gratis eBooks' - actual_plugin = 'calibre.gui2.store.stores.beam_ebooks_de_plugin:BeamEBooksDEStore' - - drm_free_only = True - headquarters = 'DE' - formats = ['EPUB', 'MOBI', 'PDF'] - affiliate = True - class StoreBeWriteStore(StoreBase): name = 'BeWrite Books' description = u'Publishers of fine books. Highly selective and editorially driven. Does not offer: books for children or exclusively YA, erotica, swords-and-sorcery fantasy and space-opera-style science fiction. All other genres are represented.' diff --git a/src/calibre/gui2/store/stores/beam_ebooks_de_plugin.py b/src/calibre/gui2/store/stores/beam_ebooks_de_plugin.py deleted file mode 100644 index 6e31a76f8d..0000000000 --- a/src/calibre/gui2/store/stores/beam_ebooks_de_plugin.py +++ /dev/null @@ -1,92 +0,0 @@ -# -*- coding: utf-8 -*- - -from __future__ import (unicode_literals, division, absolute_import, print_function) - -__license__ = 'GPL 3' -__copyright__ = '2011, John Schember ' -__docformat__ = 'restructuredtext en' - -import urllib2 -from contextlib import closing - -from lxml import html - -from PyQt4.Qt import QUrl - -from calibre import browser -from calibre.gui2 import open_url -from calibre.gui2.store import StorePlugin -from calibre.gui2.store.basic_config import BasicStoreConfig -from calibre.gui2.store.search_result import SearchResult -from calibre.gui2.store.web_store_dialog import WebStoreDialog - -class BeamEBooksDEStore(BasicStoreConfig, StorePlugin): - - def open(self, parent=None, detail_item=None, external=False): - url = 'http://klick.affiliwelt.net/klick.php?bannerid=10072&pid=32307&prid=908' - url_details = ('http://klick.affiliwelt.net/klick.php?' - 'bannerid=10730&pid=32307&prid=908&prodid={0}') - - if external or self.config.get('open_external', False): - if detail_item: - url = url_details.format(detail_item) - open_url(QUrl(url)) - else: - detail_url = None - if detail_item: - detail_url = url_details.format(detail_item) - d = WebStoreDialog(self.gui, url, parent, detail_url) - d.setWindowTitle(self.name) - d.set_tags(self.config.get('tags', '')) - d.exec_() - - def search(self, query, max_results=10, timeout=60): - url = 'http://www.beam-ebooks.de/suchergebnis.php?Type=&sw=' + urllib2.quote(query) - br = browser() - - counter = max_results - with closing(br.open(url, timeout=timeout)) as f: - doc = html.fromstring(f.read()) - for data in doc.xpath('//table[tr/td/div[@class="stil2"]]'): - if counter <= 0: - break - - id = ''.join(data.xpath('./tr/td[1]/a/@href')).strip() - if not id: - continue - id = id[7:] - cover_url = ''.join(data.xpath('./tr/td[1]/a/img/@src')) - if cover_url: - cover_url = 'http://www.beam-ebooks.de' + cover_url - temp = ''.join(data.xpath('./tr/td[1]/a/img/@alt')) - colon = temp.find(':') - if not temp.startswith('eBook') or colon < 0: - continue - author = temp[5:colon] - title = temp[colon+1:] - price = ''.join(data.xpath('./tr/td[3]/text()')) - pdf = data.xpath( - 'boolean(./tr/td[3]/a/img[contains(@alt, "PDF")]/@alt)') - epub = data.xpath( - 'boolean(./tr/td[3]/a/img[contains(@alt, "ePub")]/@alt)') - mobi = data.xpath( - 'boolean(./tr/td[3]/a/img[contains(@alt, "Mobipocket")]/@alt)') - counter -= 1 - - s = SearchResult() - s.cover_url = cover_url - s.title = title.strip() - s.author = author.strip() - s.price = price - s.drm = SearchResult.DRM_UNLOCKED - s.detail_item = id - formats = [] - if epub: - formats.append('ePub') - if pdf: - formats.append('PDF') - if mobi: - formats.append('MOBI') - s.formats = ', '.join(formats) - - yield s From 433f620b058b5ac385cb28eec104795b8dfc8cb9 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 16 Sep 2012 08:45:34 +0530 Subject: [PATCH 31/41] ... --- src/calibre/customize/builtins.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/calibre/customize/builtins.py b/src/calibre/customize/builtins.py index 708e15ee78..f46ac23772 100644 --- a/src/calibre/customize/builtins.py +++ b/src/calibre/customize/builtins.py @@ -1639,7 +1639,6 @@ plugins += [ StoreAmazonUKKindleStore, StoreBaenWebScriptionStore, StoreBNStore, StoreSonyStore, - StoreBeamEBooksDEStore, StoreBeWriteStore, StoreBiblioStore, StoreBookotekaStore, From 2112ee3e172d8f1f04d4e1fc31e3c110ab974ee9 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 16 Sep 2012 09:30:25 +0530 Subject: [PATCH 32/41] MTP driver: Change the default template to not create subfolders as apparently Amazon are even more incompetent than I thought. --- src/calibre/devices/mtp/driver.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/calibre/devices/mtp/driver.py b/src/calibre/devices/mtp/driver.py index de06955bfe..c5b874a0fa 100644 --- a/src/calibre/devices/mtp/driver.py +++ b/src/calibre/devices/mtp/driver.py @@ -45,13 +45,12 @@ class MTP_DEVICE(BASE): @property def prefs(self): if self._prefs is None: - from calibre.library.save_to_disk import config self._prefs = p = JSONConfig('mtp_devices') p.defaults['format_map'] = self.FORMATS p.defaults['send_to'] = ['Calibre_Companion', 'Books', 'eBooks/import', 'eBooks', 'wordplayer/calibretransfer', 'sdcard/ebooks', 'kindle'] - p.defaults['send_template'] = config().parse().send_template + p.defaults['send_template'] = '{title} - {authors}' p.defaults['blacklist'] = [] p.defaults['history'] = {} p.defaults['rules'] = [] @@ -291,7 +290,7 @@ class MTP_DEVICE(BASE): prefix_path=path, path_type=posixpath, maxlen=self.MAX_PATH_LEN, - use_subdirs=True, + use_subdirs='/' in self.save_template, news_in_folder=self.NEWS_IN_FOLDER, ) return tuple(x for x in filepath.split('/')) From e5e5da661ea04a971b045067085f3e0eb40a0c8a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 16 Sep 2012 13:36:39 +0530 Subject: [PATCH 33/41] Calibre Portable: Create an exe installer --- icons/install.ico | Bin 0 -> 25214 bytes setup/hosting.py | 2 +- setup/installer/windows/XUnzip.cpp | 4379 +++++++++++++++++ setup/installer/windows/XUnzip.h | 382 ++ setup/installer/windows/__init__.py | 4 +- setup/installer/windows/freeze.py | 57 +- setup/installer/windows/notes.rst | 8 + .../installer/windows/portable-installer.cpp | 547 ++ setup/upload.py | 2 +- 9 files changed, 5374 insertions(+), 7 deletions(-) create mode 100644 icons/install.ico create mode 100644 setup/installer/windows/XUnzip.cpp create mode 100644 setup/installer/windows/XUnzip.h create mode 100644 setup/installer/windows/portable-installer.cpp diff --git a/icons/install.ico b/icons/install.ico new file mode 100644 index 0000000000000000000000000000000000000000..1db75f8e4a2470b7477f7a1ca6d536a898aad40a GIT binary patch literal 25214 zcmdUX2V9iL_Vyv>Uc8zc>?F}d)EG@yb92+9DH`=^G)0X`EGRL?*o}f36)Pw~Y-sE? zv3C&>5yV2VV6TWMb}7pOyNd$zf1cTW*G0j2|DWIY`+Z~1&il?hGjry=XJ*cv86x5) z|Bwn5DhNY;H<6i$`RXQRrRU#7b|THo%btJzF_9PC`EJi&QC8&1av}{H*zrbsH}8B+%AL(Zhqf{{-w%dl*5IpJdzG~l50{_@7Qx>j}KQ_lmK)`tUy3K#&rMk7H{`0k@N|h?oUEt1KHZ_9!dCE@8xA`YIDXP$XVe~(VTPLWEpv*gvy zO1_CzGCnC^797cvh|@P@|KVeDXn(w{U%N&cKxv+@T~iWw$4FwzO;L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zs@yP&M}NJz9Js^_TAHePx=Wo7`~m7#_z-G&&n;^dEX}v_Yh(xY&xK3<8Jbltq0YJ&?V}Zaly*_ zr#=euJB{^o9ma47Y>2k6yz&ZdAIkn=#;~~F%|RU!Lw1sR.+?)(?:-(?:i686|x86_64|32bit|64bit))?\.(?:zip|exe|msi|dmg|tar\.bz2|tar\.xz|txz|tbz2)' + filename_pattern=r'{appname}-(?:portable-installer-)?(?P.+?)(?:-(?:i686|x86_64|32bit|64bit))?\.(?:zip|exe|msi|dmg|tar\.bz2|tar\.xz|txz|tbz2)' ): self.username, self.password, = username, password diff --git a/setup/installer/windows/XUnzip.cpp b/setup/installer/windows/XUnzip.cpp new file mode 100644 index 0000000000..09880378d9 --- /dev/null +++ b/setup/installer/windows/XUnzip.cpp @@ -0,0 +1,4379 @@ +// XUnzip.cpp Version 1.3 +// +// Authors: Mark Adler et al. (see below) +// +// Modified by: Lucian Wischik +// lu@wischik.com +// +// Version 1.0 - Turned C files into just a single CPP file +// - Made them compile cleanly as C++ files +// - Gave them simpler APIs +// - Added the ability to zip/unzip directly in memory without +// any intermediate files +// +// Modified by: Hans Dietrich +// hdietrich@gmail.com +// +// Version 1.3: - Corrected size bug introduced by 1.2 +// +// Version 1.2: - Many bug fixes. See CodeProject article for list. +// +// Version 1.1: - Added Unicode support to CreateZip() and ZipAdd() +// - Changed file names to avoid conflicts with Lucian's files +// +/////////////////////////////////////////////////////////////////////////////// +// +// Lucian Wischik's comments: +// -------------------------- +// THIS FILE is almost entirely based upon code by Info-ZIP. +// It has been modified by Lucian Wischik. +// The original code may be found at http://www.info-zip.org +// The original copyright text follows. +// +/////////////////////////////////////////////////////////////////////////////// +// +// Original authors' comments: +// --------------------------- +// This is version 2002-Feb-16 of the Info-ZIP copyright and license. The +// definitive version of this document should be available at +// ftp://ftp.info-zip.org/pub/infozip/license.html indefinitely. +// +// Copyright (c) 1990-2002 Info-ZIP. All rights reserved. +// +// For the purposes of this copyright and license, "Info-ZIP" is defined as +// the following set of individuals: +// +// Mark Adler, John Bush, Karl Davis, Harald Denker, Jean-Michel Dubois, +// Jean-loup Gailly, Hunter Goatley, Ian Gorman, Chris Herborth, Dirk Haase, +// Greg Hartwig, Robert Heath, Jonathan Hudson, Paul Kienitz, +// David Kirschbaum, Johnny Lee, Onno van der Linden, Igor Mandrichenko, +// Steve P. Miller, Sergio Monesi, Keith Owens, George Petrov, Greg Roelofs, +// Kai Uwe Rommel, Steve Salisbury, Dave Smith, Christian Spieler, +// Antoine Verheijen, Paul von Behren, Rich Wales, Mike White +// +// This software is provided "as is", without warranty of any kind, express +// or implied. In no event shall Info-ZIP or its contributors be held liable +// for any direct, indirect, incidental, special or consequential damages +// arising out of the use of or inability to use this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. Redistributions of source code must retain the above copyright notice, +// definition, disclaimer, and this list of conditions. +// +// 2. Redistributions in binary form (compiled executables) must reproduce +// the above copyright notice, definition, disclaimer, and this list of +// conditions in documentation and/or other materials provided with the +// distribution. The sole exception to this condition is redistribution +// of a standard UnZipSFX binary as part of a self-extracting archive; +// that is permitted without inclusion of this license, as long as the +// normal UnZipSFX banner has not been removed from the binary or disabled. +// +// 3. Altered versions--including, but not limited to, ports to new +// operating systems, existing ports with new graphical interfaces, and +// dynamic, shared, or static library versions--must be plainly marked +// as such and must not be misrepresented as being the original source. +// Such altered versions also must not be misrepresented as being +// Info-ZIP releases--including, but not limited to, labeling of the +// altered versions with the names "Info-ZIP" (or any variation thereof, +// including, but not limited to, different capitalizations), +// "Pocket UnZip", "WiZ" or "MacZip" without the explicit permission of +// Info-ZIP. Such altered versions are further prohibited from +// misrepresentative use of the Zip-Bugs or Info-ZIP e-mail addresses or +// of the Info-ZIP URL(s). +// +// 4. Info-ZIP retains the right to use the names "Info-ZIP", "Zip", "UnZip", +// "UnZipSFX", "WiZ", "Pocket UnZip", "Pocket Zip", and "MacZip" for its +// own source and binary releases. +// +/////////////////////////////////////////////////////////////////////////////// + + +#define _USE_32BIT_TIME_T //+++1.2 + + +#define STRICT +#define WIN32_LEAN_AND_MEAN +#include +#include +#include +#include +#include +#include +#include "XUnzip.h" + +#pragma warning(disable : 4996) // disable bogus deprecation warning + +// THIS FILE is almost entirely based upon code by Jean-loup Gailly +// and Mark Adler. It has been modified by Lucian Wischik. +// The original code may be found at http://www.gzip.org/zlib/ +// The original copyright text follows. +// +// +// +// zlib.h -- interface of the 'zlib' general purpose compression library +// version 1.1.3, July 9th, 1998 +// +// Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would be +// appreciated but is not required. +// 2. Altered source versions must be plainly marked as such, and must not be +// misrepresented as being the original software. +// 3. This notice may not be removed or altered from any source distribution. +// +// Jean-loup Gailly Mark Adler +// jloup@gzip.org madler@alumni.caltech.edu +// +// +// The data format used by the zlib library is described by RFCs (Request for +// Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt +// (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). +// +// +// The 'zlib' compression library provides in-memory compression and +// decompression functions, including integrity checks of the uncompressed +// data. This version of the library supports only one compression method +// (deflation) but other algorithms will be added later and will have the same +// stream interface. +// +// Compression can be done in a single step if the buffers are large +// enough (for example if an input file is mmap'ed), or can be done by +// repeated calls of the compression function. In the latter case, the +// application must provide more input and/or consume the output +// (providing more output space) before each call. +// +// The library also supports reading and writing files in gzip (.gz) format +// with an interface similar to that of stdio. +// +// The library does not install any signal handler. The decoder checks +// the consistency of the compressed data, so the library should never +// crash even in case of corrupted input. +// +// for more info about .ZIP format, see ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip +// PkWare has also a specification at ftp://ftp.pkware.com/probdesc.zip + +#define zmalloc(len) malloc(len) + +#define zfree(p) free(p) + +/* +void *zmalloc(unsigned int len) +{ char *buf = new char[len+32]; + for (int i=0; i<16; i++) + { buf[i]=i; + buf[len+31-i]=i; + } + *((unsigned int*)buf) = len; + char c[1000]; wsprintf(c,"malloc 0x%lx - %lu",buf+16,len); + OutputDebugString(c); + return buf+16; +} + +void zfree(void *buf) +{ char c[1000]; wsprintf(c,"free 0x%lx",buf); + OutputDebugString(c); + char *p = ((char*)buf)-16; + unsigned int len = *((unsigned int*)p); + bool blown=false; + for (int i=0; i<16; i++) + { char lo = p[i]; + char hi = p[len+31-i]; + if (hi!=i || (lo!=i && i>4)) blown=true; + } + if (blown) + { OutputDebugString("BLOWN!!!"); + } + delete[] p; +} +*/ + +#pragma warning(disable : 4702) // unreachable code + +static ZRESULT zopenerror = ZR_OK; //+++1.2 + +typedef struct tm_unz_s +{ unsigned int tm_sec; // seconds after the minute - [0,59] + unsigned int tm_min; // minutes after the hour - [0,59] + unsigned int tm_hour; // hours since midnight - [0,23] + unsigned int tm_mday; // day of the month - [1,31] + unsigned int tm_mon; // months since January - [0,11] + unsigned int tm_year; // years - [1980..2044] +} tm_unz; + + +// unz_global_info structure contain global data about the ZIPfile +typedef struct unz_global_info_s +{ unsigned long number_entry; // total number of entries in the central dir on this disk + unsigned long size_comment; // size of the global comment of the zipfile +} unz_global_info; + +// unz_file_info contain information about a file in the zipfile +typedef struct unz_file_info_s +{ unsigned long version; // version made by 2 bytes + unsigned long version_needed; // version needed to extract 2 bytes + unsigned long flag; // general purpose bit flag 2 bytes + unsigned long compression_method; // compression method 2 bytes + unsigned long dosDate; // last mod file date in Dos fmt 4 bytes + unsigned long crc; // crc-32 4 bytes + unsigned long compressed_size; // compressed size 4 bytes + unsigned long uncompressed_size; // uncompressed size 4 bytes + unsigned long size_filename; // filename length 2 bytes + unsigned long size_file_extra; // extra field length 2 bytes + unsigned long size_file_comment; // file comment length 2 bytes + unsigned long disk_num_start; // disk number start 2 bytes + unsigned long internal_fa; // internal file attributes 2 bytes + unsigned long external_fa; // external file attributes 4 bytes + tm_unz tmu_date; +} unz_file_info; + + +#define UNZ_OK (0) +#define UNZ_END_OF_LIST_OF_FILE (-100) +#define UNZ_ERRNO (Z_ERRNO) +#define UNZ_EOF (0) +#define UNZ_PARAMERROR (-102) +#define UNZ_BADZIPFILE (-103) +#define UNZ_INTERNALERROR (-104) +#define UNZ_CRCERROR (-105) + + + + + + + +#define ZLIB_VERSION "1.1.3" + + +// Allowed flush values; see deflate() for details +#define Z_NO_FLUSH 0 +#define Z_SYNC_FLUSH 2 +#define Z_FULL_FLUSH 3 +#define Z_FINISH 4 + + +// compression levels +#define Z_NO_COMPRESSION 0 +#define Z_BEST_SPEED 1 +#define Z_BEST_COMPRESSION 9 +#define Z_DEFAULT_COMPRESSION (-1) + +// compression strategy; see deflateInit2() for details +#define Z_FILTERED 1 +#define Z_HUFFMAN_ONLY 2 +#define Z_DEFAULT_STRATEGY 0 + +// Possible values of the data_type field +#define Z_BINARY 0 +#define Z_ASCII 1 +#define Z_UNKNOWN 2 + +// The deflate compression method (the only one supported in this version) +#define Z_DEFLATED 8 + +// for initializing zalloc, zfree, opaque +#define Z_NULL 0 + +// case sensitivity when searching for filenames +#define CASE_SENSITIVE 1 +#define CASE_INSENSITIVE 2 + + +// Return codes for the compression/decompression functions. Negative +// values are errors, positive values are used for special but normal events. +#define Z_OK 0 +#define Z_STREAM_END 1 +#define Z_NEED_DICT 2 +#define Z_ERRNO (-1) +#define Z_STREAM_ERROR (-2) +#define Z_DATA_ERROR (-3) +#define Z_MEM_ERROR (-4) +#define Z_BUF_ERROR (-5) +#define Z_VERSION_ERROR (-6) + + + +// Basic data types +typedef unsigned char Byte; // 8 bits +typedef unsigned int uInt; // 16 bits or more +typedef unsigned long uLong; // 32 bits or more +typedef void *voidpf; +typedef void *voidp; +typedef long z_off_t; + + + + + + + + + + + + +typedef voidpf (*alloc_func) (voidpf opaque, uInt items, uInt size); +typedef void (*free_func) (voidpf opaque, voidpf address); + +struct internal_state; + +typedef struct z_stream_s { + Byte *next_in; // next input byte + uInt avail_in; // number of bytes available at next_in + uLong total_in; // total nb of input bytes read so far + + Byte *next_out; // next output byte should be put there + uInt avail_out; // remaining free space at next_out + uLong total_out; // total nb of bytes output so far + + char *msg; // last error message, NULL if no error + struct internal_state *state; // not visible by applications + + alloc_func zalloc; // used to allocate the internal state + free_func zfree; // used to free the internal state + voidpf opaque; // private data object passed to zalloc and zfree + + int data_type; // best guess about the data type: ascii or binary + uLong adler; // adler32 value of the uncompressed data + uLong reserved; // reserved for future use +} z_stream; + +typedef z_stream *z_streamp; + + +// The application must update next_in and avail_in when avail_in has +// dropped to zero. It must update next_out and avail_out when avail_out +// has dropped to zero. The application must initialize zalloc, zfree and +// opaque before calling the init function. All other fields are set by the +// compression library and must not be updated by the application. +// +// The opaque value provided by the application will be passed as the first +// parameter for calls of zalloc and zfree. This can be useful for custom +// memory management. The compression library attaches no meaning to the +// opaque value. +// +// zalloc must return Z_NULL if there is not enough memory for the object. +// If zlib is used in a multi-threaded application, zalloc and zfree must be +// thread safe. +// +// The fields total_in and total_out can be used for statistics or +// progress reports. After compression, total_in holds the total size of +// the uncompressed data and may be saved for use in the decompressor +// (particularly if the decompressor wants to decompress everything in +// a single step). +// + + +// basic functions + +const char *zlibVersion (); +// The application can compare zlibVersion and ZLIB_VERSION for consistency. +// If the first character differs, the library code actually used is +// not compatible with the zlib.h header file used by the application. +// This check is automatically made by inflateInit. + + + + + + +int inflate (z_streamp strm, int flush); +// +// inflate decompresses as much data as possible, and stops when the input +// buffer becomes empty or the output buffer becomes full. It may some +// introduce some output latency (reading input without producing any output) +// except when forced to flush. +// +// The detailed semantics are as follows. inflate performs one or both of the +// following actions: +// +// - Decompress more input starting at next_in and update next_in and avail_in +// accordingly. If not all input can be processed (because there is not +// enough room in the output buffer), next_in is updated and processing +// will resume at this point for the next call of inflate(). +// +// - Provide more output starting at next_out and update next_out and avail_out +// accordingly. inflate() provides as much output as possible, until there +// is no more input data or no more space in the output buffer (see below +// about the flush parameter). +// +// Before the call of inflate(), the application should ensure that at least +// one of the actions is possible, by providing more input and/or consuming +// more output, and updating the next_* and avail_* values accordingly. +// The application can consume the uncompressed output when it wants, for +// example when the output buffer is full (avail_out == 0), or after each +// call of inflate(). If inflate returns Z_OK and with zero avail_out, it +// must be called again after making room in the output buffer because there +// might be more output pending. +// +// If the parameter flush is set to Z_SYNC_FLUSH, inflate flushes as much +// output as possible to the output buffer. The flushing behavior of inflate is +// not specified for values of the flush parameter other than Z_SYNC_FLUSH +// and Z_FINISH, but the current implementation actually flushes as much output +// as possible anyway. +// +// inflate() should normally be called until it returns Z_STREAM_END or an +// error. However if all decompression is to be performed in a single step +// (a single call of inflate), the parameter flush should be set to +// Z_FINISH. In this case all pending input is processed and all pending +// output is flushed; avail_out must be large enough to hold all the +// uncompressed data. (The size of the uncompressed data may have been saved +// by the compressor for this purpose.) The next operation on this stream must +// be inflateEnd to deallocate the decompression state. The use of Z_FINISH +// is never required, but can be used to inform inflate that a faster routine +// may be used for the single inflate() call. +// +// If a preset dictionary is needed at this point (see inflateSetDictionary +// below), inflate sets strm-adler to the adler32 checksum of the +// dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise +// it sets strm->adler to the adler32 checksum of all output produced +// so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or +// an error code as described below. At the end of the stream, inflate() +// checks that its computed adler32 checksum is equal to that saved by the +// compressor and returns Z_STREAM_END only if the checksum is correct. +// +// inflate() returns Z_OK if some progress has been made (more input processed +// or more output produced), Z_STREAM_END if the end of the compressed data has +// been reached and all uncompressed output has been produced, Z_NEED_DICT if a +// preset dictionary is needed at this point, Z_DATA_ERROR if the input data was +// corrupted (input stream not conforming to the zlib format or incorrect +// adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent +// (for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not +// enough memory, Z_BUF_ERROR if no progress is possible or if there was not +// enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR +// case, the application may then call inflateSync to look for a good +// compression block. +// + + +int inflateEnd (z_streamp strm); +// +// All dynamically allocated data structures for this stream are freed. +// This function discards any unprocessed input and does not flush any +// pending output. +// +// inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state +// was inconsistent. In the error case, msg may be set but then points to a +// static string (which must not be deallocated). + + // Advanced functions + +// The following functions are needed only in some special applications. + + + + + +int inflateSetDictionary (z_streamp strm, + const Byte *dictionary, + uInt dictLength); +// +// Initializes the decompression dictionary from the given uncompressed byte +// sequence. This function must be called immediately after a call of inflate +// if this call returned Z_NEED_DICT. The dictionary chosen by the compressor +// can be determined from the Adler32 value returned by this call of +// inflate. The compressor and decompressor must use exactly the same +// dictionary. +// +// inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a +// parameter is invalid (such as NULL dictionary) or the stream state is +// inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the +// expected one (incorrect Adler32 value). inflateSetDictionary does not +// perform any decompression: this will be done by subsequent calls of +// inflate(). + + +int inflateSync (z_streamp strm); +// +// Skips invalid compressed data until a full flush point can be found, or until all +// available input is skipped. No output is provided. +// +// inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR +// if no more input was provided, Z_DATA_ERROR if no flush point has been found, +// or Z_STREAM_ERROR if the stream structure was inconsistent. In the success +// case, the application may save the current current value of total_in which +// indicates where valid compressed data was found. In the error case, the +// application may repeatedly call inflateSync, providing more input each time, +// until success or end of the input data. + + +int inflateReset (z_streamp strm); +// This function is equivalent to inflateEnd followed by inflateInit, +// but does not free and reallocate all the internal decompression state. +// The stream will keep attributes that may have been set by inflateInit2. +// +// inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source +// stream state was inconsistent (such as zalloc or state being NULL). +// + + + +// checksum functions +// These functions are not related to compression but are exported +// anyway because they might be useful in applications using the +// compression library. + +uLong adler32 (uLong adler, const Byte *buf, uInt len); +// Update a running Adler-32 checksum with the bytes buf[0..len-1] and +// return the updated checksum. If buf is NULL, this function returns +// the required initial value for the checksum. +// An Adler-32 checksum is almost as reliable as a CRC32 but can be computed +// much faster. Usage example: +// +// uLong adler = adler32(0L, Z_NULL, 0); +// +// while (read_buffer(buffer, length) != EOF) { +// adler = adler32(adler, buffer, length); +// } +// if (adler != original_adler) error(); + +uLong ucrc32 (uLong crc, const Byte *buf, uInt len); +// Update a running crc with the bytes buf[0..len-1] and return the updated +// crc. If buf is NULL, this function returns the required initial value +// for the crc. Pre- and post-conditioning (one's complement) is performed +// within this function so it shouldn't be done by the application. +// Usage example: +// +// uLong crc = crc32(0L, Z_NULL, 0); +// +// while (read_buffer(buffer, length) != EOF) { +// crc = crc32(crc, buffer, length); +// } +// if (crc != original_crc) error(); + + + + +const char *zError (int err); +int inflateSyncPoint (z_streamp z); +const uLong *get_crc_table (void); + + + +typedef unsigned char uch; +typedef uch uchf; +typedef unsigned short ush; +typedef ush ushf; +typedef unsigned long ulg; + + + +const char * const z_errmsg[10] = { // indexed by 2-zlib_error +"need dictionary", // Z_NEED_DICT 2 +"stream end", // Z_STREAM_END 1 +"", // Z_OK 0 +"file error", // Z_ERRNO (-1) +"stream error", // Z_STREAM_ERROR (-2) +"data error", // Z_DATA_ERROR (-3) +"insufficient memory", // Z_MEM_ERROR (-4) +"buffer error", // Z_BUF_ERROR (-5) +"incompatible version",// Z_VERSION_ERROR (-6) +""}; + + +#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] + +#define ERR_RETURN(strm,err) \ + return (strm->msg = (char*)ERR_MSG(err), (err)) +// To be used only when the state is known to be valid + + // common constants + + +#define STORED_BLOCK 0 +#define STATIC_TREES 1 +#define DYN_TREES 2 +// The three kinds of block type + +#define MIN_MATCH 3 +#define MAX_MATCH 258 +// The minimum and maximum match lengths + +#define PRESET_DICT 0x20 // preset dictionary flag in zlib header + + // target dependencies + +#define OS_CODE 0x0b // Window 95 & Windows NT + + + + // functions + +#define zmemzero(dest, len) memset(dest, 0, len) + +// Diagnostic functions +#undef Assert +#undef Trace +#undef Tracev +#undef Tracevv +#undef Tracec +#undef Tracecv + +#ifdef DEBUG + + int z_verbose = 0; + void z_error (char *m) {fprintf(stderr, "%s\n", m); exit(1);} + +#define Assert(cond,msg) {if(!(cond)) z_error(msg);} +#define Trace(x) {if (z_verbose>=0) fprintf x ;} +#define Tracev(x) {if (z_verbose>0) fprintf x ;} +#define Tracevv(x) {if (z_verbose>1) fprintf x ;} +#define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} +#define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} + +#else + +#ifndef __noop +#if _MSC_VER < 1300 +#define __noop ((void)0) +#endif +#endif + +#define Assert(cond,msg) __noop +#define Trace(x) __noop +#define Tracev(x) __noop +#define Tracevv(x) __noop +#define Tracec(c,x) __noop +#define Tracecv(c,x) __noop + +#endif + + +typedef uLong (*check_func) (uLong check, const Byte *buf, uInt len); +voidpf zcalloc (voidpf opaque, unsigned items, unsigned size); +void zcfree (voidpf opaque, voidpf ptr); + +#define ZALLOC(strm, items, size) \ + (*((strm)->zalloc))((strm)->opaque, (items), (size)) +#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) + +//void ZFREE(z_streamp strm,voidpf addr) +//{ *((strm)->zfree))((strm)->opaque, addr); +//} + +#define TRY_FREE(s, p) {if (p) ZFREE(s, p);} + + + + +// Huffman code lookup table entry--this entry is four bytes for machines +// that have 16-bit pointers (e.g. PC's in the small or medium model). + + +typedef struct inflate_huft_s inflate_huft; + +struct inflate_huft_s { + union { + struct { + Byte Exop; // number of extra bits or operation + Byte Bits; // number of bits in this code or subcode + } what; + uInt pad; // pad structure to a power of 2 (4 bytes for + } word; // 16-bit, 8 bytes for 32-bit int's) + uInt base; // literal, length base, distance base, or table offset +}; + +// Maximum size of dynamic tree. The maximum found in a long but non- +// exhaustive search was 1004 huft structures (850 for length/literals +// and 154 for distances, the latter actually the result of an +// exhaustive search). The actual maximum is not known, but the +// value below is more than safe. +#define MANY 1440 + +int inflate_trees_bits ( + uInt *, // 19 code lengths + uInt *, // bits tree desired/actual depth + inflate_huft * *, // bits tree result + inflate_huft *, // space for trees + z_streamp); // for messages + +int inflate_trees_dynamic ( + uInt, // number of literal/length codes + uInt, // number of distance codes + uInt *, // that many (total) code lengths + uInt *, // literal desired/actual bit depth + uInt *, // distance desired/actual bit depth + inflate_huft * *, // literal/length tree result + inflate_huft * *, // distance tree result + inflate_huft *, // space for trees + z_streamp); // for messages + +int inflate_trees_fixed ( + uInt *, // literal desired/actual bit depth + uInt *, // distance desired/actual bit depth + const inflate_huft * *, // literal/length tree result + const inflate_huft * *, // distance tree result + z_streamp); // for memory allocation + + + + + +struct inflate_blocks_state; +typedef struct inflate_blocks_state inflate_blocks_statef; + +inflate_blocks_statef * inflate_blocks_new ( + z_streamp z, + check_func c, // check function + uInt w); // window size + +int inflate_blocks ( + inflate_blocks_statef *, + z_streamp , + int); // initial return code + +void inflate_blocks_reset ( + inflate_blocks_statef *, + z_streamp , + uLong *); // check value on output + +int inflate_blocks_free ( + inflate_blocks_statef *, + z_streamp); + +void inflate_set_dictionary ( + inflate_blocks_statef *s, + const Byte *d, // dictionary + uInt n); // dictionary length + +int inflate_blocks_sync_point ( + inflate_blocks_statef *s); + + + + +struct inflate_codes_state; +typedef struct inflate_codes_state inflate_codes_statef; + +inflate_codes_statef *inflate_codes_new ( + uInt, uInt, + const inflate_huft *, const inflate_huft *, + z_streamp ); + +int inflate_codes ( + inflate_blocks_statef *, + z_streamp , + int); + +void inflate_codes_free ( + inflate_codes_statef *, + z_streamp ); + + + + +typedef enum { + IBM_TYPE, // get type bits (3, including end bit) + IBM_LENS, // get lengths for stored + IBM_STORED, // processing stored block + IBM_TABLE, // get table lengths + IBM_BTREE, // get bit lengths tree for a dynamic block + IBM_DTREE, // get length, distance trees for a dynamic block + IBM_CODES, // processing fixed or dynamic block + IBM_DRY, // output remaining window bytes + IBM_DONE, // finished last block, done + IBM_BAD} // got a data error--stuck here +inflate_block_mode; + +// inflate blocks semi-private state +struct inflate_blocks_state { + + // mode + inflate_block_mode mode; // current inflate_block mode + + // mode dependent information + union { + uInt left; // if STORED, bytes left to copy + struct { + uInt table; // table lengths (14 bits) + uInt index; // index into blens (or border) + uInt *blens; // bit lengths of codes + uInt bb; // bit length tree depth + inflate_huft *tb; // bit length decoding tree + } trees; // if DTREE, decoding info for trees + struct { + inflate_codes_statef + *codes; + } decode; // if CODES, current state + } sub; // submode + uInt last; // true if this block is the last block + + // mode independent information + uInt bitk; // bits in bit buffer + uLong bitb; // bit buffer + inflate_huft *hufts; // single malloc for tree space + Byte *window; // sliding window + Byte *end; // one byte after sliding window + Byte *read; // window read pointer + Byte *write; // window write pointer + check_func checkfn; // check function + uLong check; // check on output + +}; + + +// defines for inflate input/output +// update pointers and return +#define UPDBITS {s->bitb=b;s->bitk=k;} +#define UPDIN {z->avail_in=n;z->total_in+=(uLong)(p-z->next_in);z->next_in=p;} +#define UPDOUT {s->write=q;} +#define UPDATE {UPDBITS UPDIN UPDOUT} +#define LEAVE {UPDATE return inflate_flush(s,z,r);} +// get bytes and bits +#define LOADIN {p=z->next_in;n=z->avail_in;b=s->bitb;k=s->bitk;} +#define NEEDBYTE {if(n)r=Z_OK;else LEAVE} +#define NEXTBYTE (n--,*p++) +#define NEEDBITS(j) {while(k<(j)){NEEDBYTE;b|=((uLong)NEXTBYTE)<>=(j);k-=(j);} +// output bytes +#define WAVAIL (uInt)(qread?s->read-q-1:s->end-q) +#define LOADOUT {q=s->write;m=(uInt)WAVAIL;m;} +#define WRAP {if(q==s->end&&s->read!=s->window){q=s->window;m=(uInt)WAVAIL;}} +#define FLUSH {UPDOUT r=inflate_flush(s,z,r); LOADOUT} +#define NEEDOUT {if(m==0){WRAP if(m==0){FLUSH WRAP if(m==0) LEAVE}}r=Z_OK;} +#define OUTBYTE(a) {*q++=(Byte)(a);m--;} +// load local pointers +#define LOAD {LOADIN LOADOUT} + +// masks for lower bits (size given to avoid silly warnings with Visual C++) +// And'ing with mask[n] masks the lower n bits +const uInt inflate_mask[17] = { + 0x0000, + 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff, + 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff +}; + +// copy as much as possible from the sliding window to the output area +int inflate_flush (inflate_blocks_statef *, z_streamp, int); + +int inflate_fast (uInt, uInt, const inflate_huft *, const inflate_huft *, inflate_blocks_statef *, z_streamp ); + + + +const uInt fixed_bl = 9; +const uInt fixed_bd = 5; +const inflate_huft fixed_tl[] = { + {{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115}, + {{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},192}, + {{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},160}, + {{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},224}, + {{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},144}, + {{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},208}, + {{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},176}, + {{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},240}, + {{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227}, + {{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},200}, + {{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},168}, + {{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},232}, + {{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},152}, + {{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},216}, + {{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},184}, + {{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},248}, + {{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163}, + {{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},196}, + {{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},164}, + {{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},228}, + {{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},148}, + {{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},212}, + {{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},180}, + {{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},244}, + {{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0}, + {{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},204}, + {{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},172}, + {{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},236}, + {{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},156}, + {{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},220}, + {{{82,7}},27}, {{{0,8}},110}, {{{0,8}},46}, {{{0,9}},188}, + {{{0,8}},14}, {{{0,8}},142}, {{{0,8}},78}, {{{0,9}},252}, + {{{96,7}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131}, + {{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},194}, + {{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},162}, + {{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},226}, + {{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},146}, + {{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},210}, + {{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},178}, + {{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},242}, + {{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258}, + {{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},202}, + {{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},170}, + {{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},234}, + {{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},154}, + {{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},218}, + {{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},186}, + {{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},250}, + {{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195}, + {{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},198}, + {{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},166}, + {{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},230}, + {{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},150}, + {{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},214}, + {{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},182}, + {{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},246}, + {{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0}, + {{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},206}, + {{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},174}, + {{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},238}, + {{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},158}, + {{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},222}, + {{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},190}, + {{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},254}, + {{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115}, + {{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},193}, + {{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},161}, + {{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},225}, + {{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},145}, + {{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},209}, + {{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},177}, + {{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},241}, + {{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227}, + {{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},201}, + {{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},169}, + {{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},233}, + {{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},153}, + {{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},217}, + {{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},185}, + {{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},249}, + {{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163}, + {{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},197}, + {{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},165}, + {{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},229}, + {{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},149}, + {{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},213}, + {{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},181}, + {{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},245}, + {{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0}, + {{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},205}, + {{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},173}, + {{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},237}, + {{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},157}, + {{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},221}, + {{{82,7}},27}, {{{0,8}},110}, {{{0,8}},46}, {{{0,9}},189}, + {{{0,8}},14}, {{{0,8}},142}, {{{0,8}},78}, {{{0,9}},253}, + {{{96,7}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131}, + {{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},195}, + {{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},163}, + {{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},227}, + {{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},147}, + {{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},211}, + {{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},179}, + {{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},243}, + {{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258}, + {{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},203}, + {{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},171}, + {{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},235}, + {{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},155}, + {{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},219}, + {{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},187}, + {{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},251}, + {{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195}, + {{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},199}, + {{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},167}, + {{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},231}, + {{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},151}, + {{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},215}, + {{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},183}, + {{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},247}, + {{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0}, + {{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},207}, + {{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},175}, + {{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},239}, + {{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},159}, + {{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},223}, + {{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},191}, + {{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},255} + }; +const inflate_huft fixed_td[] = { + {{{80,5}},1}, {{{87,5}},257}, {{{83,5}},17}, {{{91,5}},4097}, + {{{81,5}},5}, {{{89,5}},1025}, {{{85,5}},65}, {{{93,5}},16385}, + {{{80,5}},3}, {{{88,5}},513}, {{{84,5}},33}, {{{92,5}},8193}, + {{{82,5}},9}, {{{90,5}},2049}, {{{86,5}},129}, {{{192,5}},24577}, + {{{80,5}},2}, {{{87,5}},385}, {{{83,5}},25}, {{{91,5}},6145}, + {{{81,5}},7}, {{{89,5}},1537}, {{{85,5}},97}, {{{93,5}},24577}, + {{{80,5}},4}, {{{88,5}},769}, {{{84,5}},49}, {{{92,5}},12289}, + {{{82,5}},13}, {{{90,5}},3073}, {{{86,5}},193}, {{{192,5}},24577} + }; + + + + + + + +// copy as much as possible from the sliding window to the output area +int inflate_flush(inflate_blocks_statef *s,z_streamp z,int r) +{ + uInt n; + Byte *p; + Byte *q; + + // local copies of source and destination pointers + p = z->next_out; + q = s->read; + + // compute number of bytes to copy as far as end of window + n = (uInt)((q <= s->write ? s->write : s->end) - q); + if (n > z->avail_out) n = z->avail_out; + if (n && r == Z_BUF_ERROR) r = Z_OK; + + // update counters + z->avail_out -= n; + z->total_out += n; + + // update check information + if (s->checkfn != Z_NULL) + z->adler = s->check = (*s->checkfn)(s->check, q, n); + + // copy as far as end of window + if (n!=0) // check for n!=0 to avoid waking up CodeGuard + { memcpy(p, q, n); + p += n; + q += n; + } + + // see if more to copy at beginning of window + if (q == s->end) + { + // wrap pointers + q = s->window; + if (s->write == s->end) + s->write = s->window; + + // compute bytes to copy + n = (uInt)(s->write - q); + if (n > z->avail_out) n = z->avail_out; + if (n && r == Z_BUF_ERROR) r = Z_OK; + + // update counters + z->avail_out -= n; + z->total_out += n; + + // update check information + if (s->checkfn != Z_NULL) + z->adler = s->check = (*s->checkfn)(s->check, q, n); + + // copy + memcpy(p, q, n); + p += n; + q += n; + } + + // update pointers + z->next_out = p; + s->read = q; + + // done + return r; +} + + + + + + +// simplify the use of the inflate_huft type with some defines +#define exop word.what.Exop +#define bits word.what.Bits + +typedef enum { // waiting for "i:"=input, "o:"=output, "x:"=nothing + START, // x: set up for LEN + LEN, // i: get length/literal/eob next + LENEXT, // i: getting length extra (have base) + DIST, // i: get distance next + DISTEXT, // i: getting distance extra + COPY, // o: copying bytes in window, waiting for space + LIT, // o: got literal, waiting for output space + WASH, // o: got eob, possibly still output waiting + END, // x: got eob and all data flushed + BADCODE} // x: got error +inflate_codes_mode; + +// inflate codes private state +struct inflate_codes_state { + + // mode + inflate_codes_mode mode; // current inflate_codes mode + + // mode dependent information + uInt len; + union { + struct { + const inflate_huft *tree; // pointer into tree + uInt need; // bits needed + } code; // if LEN or DIST, where in tree + uInt lit; // if LIT, literal + struct { + uInt get; // bits to get for extra + uInt dist; // distance back to copy from + } copy; // if EXT or COPY, where and how much + } sub; // submode + + // mode independent information + Byte lbits; // ltree bits decoded per branch + Byte dbits; // dtree bits decoder per branch + const inflate_huft *ltree; // literal/length/eob tree + const inflate_huft *dtree; // distance tree + +}; + + +inflate_codes_statef *inflate_codes_new( +uInt bl, uInt bd, +const inflate_huft *tl, +const inflate_huft *td, // need separate declaration for Borland C++ +z_streamp z) +{ + inflate_codes_statef *c; + + if ((c = (inflate_codes_statef *) + ZALLOC(z,1,sizeof(struct inflate_codes_state))) != Z_NULL) + { + c->mode = START; + c->lbits = (Byte)bl; + c->dbits = (Byte)bd; + c->ltree = tl; + c->dtree = td; + Tracev((stderr, "inflate: codes new\n")); + } + return c; +} + + +int inflate_codes(inflate_blocks_statef *s, z_streamp z, int r) +{ + uInt j; // temporary storage + const inflate_huft *t; // temporary pointer + uInt e; // extra bits or operation + uLong b; // bit buffer + uInt k; // bits in bit buffer + Byte *p; // input data pointer + uInt n; // bytes available there + Byte *q; // output window write pointer + uInt m; // bytes to end of window or read pointer + Byte *f; // pointer to copy strings from + inflate_codes_statef *c = s->sub.decode.codes; // codes state + + // copy input/output information to locals (UPDATE macro restores) + LOAD + + // process input and output based on current state + for(;;) switch (c->mode) + { // waiting for "i:"=input, "o:"=output, "x:"=nothing + case START: // x: set up for LEN +#ifndef SLOW + if (m >= 258 && n >= 10) + { + UPDATE + r = inflate_fast(c->lbits, c->dbits, c->ltree, c->dtree, s, z); + LOAD + if (r != Z_OK) + { + c->mode = r == Z_STREAM_END ? WASH : BADCODE; + break; + } + } +#endif // !SLOW + c->sub.code.need = c->lbits; + c->sub.code.tree = c->ltree; + c->mode = LEN; + case LEN: // i: get length/literal/eob next + j = c->sub.code.need; + NEEDBITS(j) + t = c->sub.code.tree + ((uInt)b & inflate_mask[j]); + DUMPBITS(t->bits) + e = (uInt)(t->exop); + if (e == 0) // literal + { + c->sub.lit = t->base; + Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ? + "inflate: literal '%c'\n" : + "inflate: literal 0x%02x\n", t->base)); + c->mode = LIT; + break; + } + if (e & 16) // length + { + c->sub.copy.get = e & 15; + c->len = t->base; + c->mode = LENEXT; + break; + } + if ((e & 64) == 0) // next table + { + c->sub.code.need = e; + c->sub.code.tree = t + t->base; + break; + } + if (e & 32) // end of block + { + Tracevv((stderr, "inflate: end of block\n")); + c->mode = WASH; + break; + } + c->mode = BADCODE; // invalid code + z->msg = (char*)"invalid literal/length code"; + r = Z_DATA_ERROR; + LEAVE + case LENEXT: // i: getting length extra (have base) + j = c->sub.copy.get; + NEEDBITS(j) + c->len += (uInt)b & inflate_mask[j]; + DUMPBITS(j) + c->sub.code.need = c->dbits; + c->sub.code.tree = c->dtree; + Tracevv((stderr, "inflate: length %u\n", c->len)); + c->mode = DIST; + case DIST: // i: get distance next + j = c->sub.code.need; + NEEDBITS(j) + t = c->sub.code.tree + ((uInt)b & inflate_mask[j]); + DUMPBITS(t->bits) + e = (uInt)(t->exop); + if (e & 16) // distance + { + c->sub.copy.get = e & 15; + c->sub.copy.dist = t->base; + c->mode = DISTEXT; + break; + } + if ((e & 64) == 0) // next table + { + c->sub.code.need = e; + c->sub.code.tree = t + t->base; + break; + } + c->mode = BADCODE; // invalid code + z->msg = (char*)"invalid distance code"; + r = Z_DATA_ERROR; + LEAVE + case DISTEXT: // i: getting distance extra + j = c->sub.copy.get; + NEEDBITS(j) + c->sub.copy.dist += (uInt)b & inflate_mask[j]; + DUMPBITS(j) + Tracevv((stderr, "inflate: distance %u\n", c->sub.copy.dist)); + c->mode = COPY; + case COPY: // o: copying bytes in window, waiting for space + f = (uInt)(q - s->window) < c->sub.copy.dist ? + s->end - (c->sub.copy.dist - (q - s->window)) : + q - c->sub.copy.dist; + while (c->len) + { + NEEDOUT + OUTBYTE(*f++) + if (f == s->end) + f = s->window; + c->len--; + } + c->mode = START; + break; + case LIT: // o: got literal, waiting for output space + NEEDOUT + OUTBYTE(c->sub.lit) + c->mode = START; + break; + case WASH: // o: got eob, possibly more output + if (k > 7) // return unused byte, if any + { + Assert(k < 16, "inflate_codes grabbed too many bytes"); + k -= 8; + n++; + p--; // can always return one + } + FLUSH + if (s->read != s->write) + LEAVE + c->mode = END; + case END: + r = Z_STREAM_END; + LEAVE + case BADCODE: // x: got error + r = Z_DATA_ERROR; + LEAVE + default: + r = Z_STREAM_ERROR; + LEAVE + } +} + + +void inflate_codes_free(inflate_codes_statef *c,z_streamp z) +{ ZFREE(z, c); + Tracev((stderr, "inflate: codes free\n")); +} + + + +// infblock.c -- interpret and process block types to last block +// Copyright (C) 1995-1998 Mark Adler +// For conditions of distribution and use, see copyright notice in zlib.h + +//struct inflate_codes_state {int dummy;}; // for buggy compilers + + + +// Table for deflate from PKZIP's appnote.txt. +const uInt border[] = { // Order of the bit length code lengths + 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; + +// +// Notes beyond the 1.93a appnote.txt: +// +// 1. Distance pointers never point before the beginning of the output stream. +// 2. Distance pointers can point back across blocks, up to 32k away. +// 3. There is an implied maximum of 7 bits for the bit length table and +// 15 bits for the actual data. +// 4. If only one code exists, then it is encoded using one bit. (Zero +// would be more efficient, but perhaps a little confusing.) If two +// codes exist, they are coded using one bit each (0 and 1). +// 5. There is no way of sending zero distance codes--a dummy must be +// sent if there are none. (History: a pre 2.0 version of PKZIP would +// store blocks with no distance codes, but this was discovered to be +// too harsh a criterion.) Valid only for 1.93a. 2.04c does allow +// zero distance codes, which is sent as one code of zero bits in +// length. +// 6. There are up to 286 literal/length codes. Code 256 represents the +// end-of-block. Note however that the static length tree defines +// 288 codes just to fill out the Huffman codes. Codes 286 and 287 +// cannot be used though, since there is no length base or extra bits +// defined for them. Similarily, there are up to 30 distance codes. +// However, static trees define 32 codes (all 5 bits) to fill out the +// Huffman codes, but the last two had better not show up in the data. +// 7. Unzip can check dynamic Huffman blocks for complete code sets. +// The exception is that a single code would not be complete (see #4). +// 8. The five bits following the block type is really the number of +// literal codes sent minus 257. +// 9. Length codes 8,16,16 are interpreted as 13 length codes of 8 bits +// (1+6+6). Therefore, to output three times the length, you output +// three codes (1+1+1), whereas to output four times the same length, +// you only need two codes (1+3). Hmm. +//10. In the tree reconstruction algorithm, Code = Code + Increment +// only if BitLength(i) is not zero. (Pretty obvious.) +//11. Correction: 4 Bits: # of Bit Length codes - 4 (4 - 19) +//12. Note: length code 284 can represent 227-258, but length code 285 +// really is 258. The last length deserves its own, short code +// since it gets used a lot in very redundant files. The length +// 258 is special since 258 - 3 (the min match length) is 255. +//13. The literal/length and distance code bit lengths are read as a +// single stream of lengths. It is possible (and advantageous) for +// a repeat code (16, 17, or 18) to go across the boundary between +// the two sets of lengths. + + +void inflate_blocks_reset(inflate_blocks_statef *s, z_streamp z, uLong *c) +{ + if (c != Z_NULL) + *c = s->check; + if (s->mode == IBM_BTREE || s->mode == IBM_DTREE) + ZFREE(z, s->sub.trees.blens); + if (s->mode == IBM_CODES) + inflate_codes_free(s->sub.decode.codes, z); + s->mode = IBM_TYPE; + s->bitk = 0; + s->bitb = 0; + s->read = s->write = s->window; + if (s->checkfn != Z_NULL) + z->adler = s->check = (*s->checkfn)(0L, (const Byte *)Z_NULL, 0); + Tracev((stderr, "inflate: blocks reset\n")); +} + + +inflate_blocks_statef *inflate_blocks_new(z_streamp z, check_func c, uInt w) +{ + inflate_blocks_statef *s; + + if ((s = (inflate_blocks_statef *)ZALLOC + (z,1,sizeof(struct inflate_blocks_state))) == Z_NULL) + return s; + if ((s->hufts = + (inflate_huft *)ZALLOC(z, sizeof(inflate_huft), MANY)) == Z_NULL) + { + ZFREE(z, s); + return Z_NULL; + } + if ((s->window = (Byte *)ZALLOC(z, 1, w)) == Z_NULL) + { + ZFREE(z, s->hufts); + ZFREE(z, s); + return Z_NULL; + } + s->end = s->window + w; + s->checkfn = c; + s->mode = IBM_TYPE; + Tracev((stderr, "inflate: blocks allocated\n")); + inflate_blocks_reset(s, z, Z_NULL); + return s; +} + + +int inflate_blocks(inflate_blocks_statef *s, z_streamp z, int r) +{ + uInt t; // temporary storage + uLong b; // bit buffer + uInt k; // bits in bit buffer + Byte *p; // input data pointer + uInt n; // bytes available there + Byte *q; // output window write pointer + uInt m; // bytes to end of window or read pointer + + // copy input/output information to locals (UPDATE macro restores) + LOAD + + // process input based on current state + for(;;) switch (s->mode) + { + case IBM_TYPE: + NEEDBITS(3) + t = (uInt)b & 7; + s->last = t & 1; + switch (t >> 1) + { + case 0: // stored + Tracev((stderr, "inflate: stored block%s\n", + s->last ? " (last)" : "")); + DUMPBITS(3) + t = k & 7; // go to byte boundary + DUMPBITS(t) + s->mode = IBM_LENS; // get length of stored block + break; + case 1: // fixed + Tracev((stderr, "inflate: fixed codes block%s\n", + s->last ? " (last)" : "")); + { + uInt bl, bd; + const inflate_huft *tl, *td; + + inflate_trees_fixed(&bl, &bd, &tl, &td, z); + s->sub.decode.codes = inflate_codes_new(bl, bd, tl, td, z); + if (s->sub.decode.codes == Z_NULL) + { + r = Z_MEM_ERROR; + LEAVE + } + } + DUMPBITS(3) + s->mode = IBM_CODES; + break; + case 2: // dynamic + Tracev((stderr, "inflate: dynamic codes block%s\n", + s->last ? " (last)" : "")); + DUMPBITS(3) + s->mode = IBM_TABLE; + break; + case 3: // illegal + DUMPBITS(3) + s->mode = IBM_BAD; + z->msg = (char*)"invalid block type"; + r = Z_DATA_ERROR; + LEAVE + } + break; + case IBM_LENS: + NEEDBITS(32) + if ((((~b) >> 16) & 0xffff) != (b & 0xffff)) + { + s->mode = IBM_BAD; + z->msg = (char*)"invalid stored block lengths"; + r = Z_DATA_ERROR; + LEAVE + } + s->sub.left = (uInt)b & 0xffff; + b = k = 0; // dump bits + Tracev((stderr, "inflate: stored length %u\n", s->sub.left)); + s->mode = s->sub.left ? IBM_STORED : (s->last ? IBM_DRY : IBM_TYPE); + break; + case IBM_STORED: + if (n == 0) + LEAVE + NEEDOUT + t = s->sub.left; + if (t > n) t = n; + if (t > m) t = m; + memcpy(q, p, t); + p += t; n -= t; + q += t; m -= t; + if ((s->sub.left -= t) != 0) + break; + Tracev((stderr, "inflate: stored end, %lu total out\n", + z->total_out + (q >= s->read ? q - s->read : + (s->end - s->read) + (q - s->window)))); + s->mode = s->last ? IBM_DRY : IBM_TYPE; + break; + case IBM_TABLE: + NEEDBITS(14) + s->sub.trees.table = t = (uInt)b & 0x3fff; + // remove this section to workaround bug in pkzip + if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29) + { + s->mode = IBM_BAD; + z->msg = (char*)"too many length or distance symbols"; + r = Z_DATA_ERROR; + LEAVE + } + // end remove + t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f); + if ((s->sub.trees.blens = (uInt*)ZALLOC(z, t, sizeof(uInt))) == Z_NULL) + { + r = Z_MEM_ERROR; + LEAVE + } + DUMPBITS(14) + s->sub.trees.index = 0; + Tracev((stderr, "inflate: table sizes ok\n")); + s->mode = IBM_BTREE; + case IBM_BTREE: + while (s->sub.trees.index < 4 + (s->sub.trees.table >> 10)) + { + NEEDBITS(3) + s->sub.trees.blens[border[s->sub.trees.index++]] = (uInt)b & 7; + DUMPBITS(3) + } + while (s->sub.trees.index < 19) + s->sub.trees.blens[border[s->sub.trees.index++]] = 0; + s->sub.trees.bb = 7; + t = inflate_trees_bits(s->sub.trees.blens, &s->sub.trees.bb, + &s->sub.trees.tb, s->hufts, z); + if (t != Z_OK) + { + ZFREE(z, s->sub.trees.blens); + r = t; + if (r == Z_DATA_ERROR) + s->mode = IBM_BAD; + LEAVE + } + s->sub.trees.index = 0; + Tracev((stderr, "inflate: bits tree ok\n")); + s->mode = IBM_DTREE; + case IBM_DTREE: + while (t = s->sub.trees.table, + s->sub.trees.index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f)) + { + inflate_huft *h; + uInt i, j, c; + + t = s->sub.trees.bb; + NEEDBITS(t) + h = s->sub.trees.tb + ((uInt)b & inflate_mask[t]); + t = h->bits; + c = h->base; + if (c < 16) + { + DUMPBITS(t) + s->sub.trees.blens[s->sub.trees.index++] = c; + } + else // c == 16..18 + { + i = c == 18 ? 7 : c - 14; + j = c == 18 ? 11 : 3; + NEEDBITS(t + i) + DUMPBITS(t) + j += (uInt)b & inflate_mask[i]; + DUMPBITS(i) + i = s->sub.trees.index; + t = s->sub.trees.table; + if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) || + (c == 16 && i < 1)) + { + ZFREE(z, s->sub.trees.blens); + s->mode = IBM_BAD; + z->msg = (char*)"invalid bit length repeat"; + r = Z_DATA_ERROR; + LEAVE + } + c = c == 16 ? s->sub.trees.blens[i - 1] : 0; + do { + s->sub.trees.blens[i++] = c; + } while (--j); + s->sub.trees.index = i; + } + } + s->sub.trees.tb = Z_NULL; + { + uInt bl, bd; + inflate_huft *tl, *td; + inflate_codes_statef *c; + + bl = 9; // must be <= 9 for lookahead assumptions + bd = 6; // must be <= 9 for lookahead assumptions + t = s->sub.trees.table; + t = inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f), + s->sub.trees.blens, &bl, &bd, &tl, &td, + s->hufts, z); + ZFREE(z, s->sub.trees.blens); + if (t != Z_OK) + { + if (t == (uInt)Z_DATA_ERROR) + s->mode = IBM_BAD; + r = t; + LEAVE + } + Tracev((stderr, "inflate: trees ok\n")); + if ((c = inflate_codes_new(bl, bd, tl, td, z)) == Z_NULL) + { + r = Z_MEM_ERROR; + LEAVE + } + s->sub.decode.codes = c; + } + s->mode = IBM_CODES; + case IBM_CODES: + UPDATE + if ((r = inflate_codes(s, z, r)) != Z_STREAM_END) + return inflate_flush(s, z, r); + r = Z_OK; + inflate_codes_free(s->sub.decode.codes, z); + LOAD + Tracev((stderr, "inflate: codes end, %lu total out\n", + z->total_out + (q >= s->read ? q - s->read : + (s->end - s->read) + (q - s->window)))); + if (!s->last) + { + s->mode = IBM_TYPE; + break; + } + s->mode = IBM_DRY; + case IBM_DRY: + FLUSH + if (s->read != s->write) + LEAVE + s->mode = IBM_DONE; + case IBM_DONE: + r = Z_STREAM_END; + LEAVE + case IBM_BAD: + r = Z_DATA_ERROR; + LEAVE + default: + r = Z_STREAM_ERROR; + LEAVE + } +} + + +int inflate_blocks_free(inflate_blocks_statef *s, z_streamp z) +{ + inflate_blocks_reset(s, z, Z_NULL); + ZFREE(z, s->window); + ZFREE(z, s->hufts); + ZFREE(z, s); + Tracev((stderr, "inflate: blocks freed\n")); + return Z_OK; +} + + + +// inftrees.c -- generate Huffman trees for efficient decoding +// Copyright (C) 1995-1998 Mark Adler +// For conditions of distribution and use, see copyright notice in zlib.h +// + + + +extern const char inflate_copyright[] = + " ";//inflate 1.1.3 Copyright 1995-1998 Mark Adler "; +// If you use the zlib library in a product, an acknowledgment is welcome +// in the documentation of your product. If for some reason you cannot +// include such an acknowledgment, I would appreciate that you keep this +// copyright string in the executable of your product. + + + +int huft_build ( + uInt *, // code lengths in bits + uInt, // number of codes + uInt, // number of "simple" codes + const uInt *, // list of base values for non-simple codes + const uInt *, // list of extra bits for non-simple codes + inflate_huft **,// result: starting table + uInt *, // maximum lookup bits (returns actual) + inflate_huft *, // space for trees + uInt *, // hufts used in space + uInt * ); // space for values + +// Tables for deflate from PKZIP's appnote.txt. +const uInt cplens[31] = { // Copy lengths for literal codes 257..285 + 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, + 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; + // see note #13 above about 258 +const uInt cplext[31] = { // Extra bits for literal codes 257..285 + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, + 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 112, 112}; // 112==invalid +const uInt cpdist[30] = { // Copy offsets for distance codes 0..29 + 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, + 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, + 8193, 12289, 16385, 24577}; +const uInt cpdext[30] = { // Extra bits for distance codes + 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, + 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, + 12, 12, 13, 13}; + +// +// Huffman code decoding is performed using a multi-level table lookup. +// The fastest way to decode is to simply build a lookup table whose +// size is determined by the longest code. However, the time it takes +// to build this table can also be a factor if the data being decoded +// is not very long. The most common codes are necessarily the +// shortest codes, so those codes dominate the decoding time, and hence +// the speed. The idea is you can have a shorter table that decodes the +// shorter, more probable codes, and then point to subsidiary tables for +// the longer codes. The time it costs to decode the longer codes is +// then traded against the time it takes to make longer tables. +// +// This results of this trade are in the variables lbits and dbits +// below. lbits is the number of bits the first level table for literal/ +// length codes can decode in one step, and dbits is the same thing for +// the distance codes. Subsequent tables are also less than or equal to +// those sizes. These values may be adjusted either when all of the +// codes are shorter than that, in which case the longest code length in +// bits is used, or when the shortest code is *longer* than the requested +// table size, in which case the length of the shortest code in bits is +// used. +// +// There are two different values for the two tables, since they code a +// different number of possibilities each. The literal/length table +// codes 286 possible values, or in a flat code, a little over eight +// bits. The distance table codes 30 possible values, or a little less +// than five bits, flat. The optimum values for speed end up being +// about one bit more than those, so lbits is 8+1 and dbits is 5+1. +// The optimum values may differ though from machine to machine, and +// possibly even between compilers. Your mileage may vary. +// + + +// If BMAX needs to be larger than 16, then h and x[] should be uLong. +#define BMAX 15 // maximum bit length of any code + +int huft_build( +uInt *b, // code lengths in bits (all assumed <= BMAX) +uInt n, // number of codes (assumed <= 288) +uInt s, // number of simple-valued codes (0..s-1) +const uInt *d, // list of base values for non-simple codes +const uInt *e, // list of extra bits for non-simple codes +inflate_huft * *t, // result: starting table +uInt *m, // maximum lookup bits, returns actual +inflate_huft *hp, // space for trees +uInt *hn, // hufts used in space +uInt *v) // working area: values in order of bit length +// Given a list of code lengths and a maximum table size, make a set of +// tables to decode that set of codes. Return Z_OK on success, Z_BUF_ERROR +// if the given code set is incomplete (the tables are still built in this +// case), Z_DATA_ERROR if the input is invalid (an over-subscribed set of +// lengths), or Z_MEM_ERROR if not enough memory. +{ + + uInt a; // counter for codes of length k + uInt c[BMAX+1]; // bit length count table + uInt f; // i repeats in table every f entries + int g; // maximum code length + int h; // table level + register uInt i; // counter, current code + register uInt j; // counter + register int k; // number of bits in current code + int l; // bits per table (returned in m) + uInt mask; // (1 << w) - 1, to avoid cc -O bug on HP + register uInt *p; // pointer into c[], b[], or v[] + inflate_huft *q; // points to current table + struct inflate_huft_s r; // table entry for structure assignment + inflate_huft *u[BMAX]; // table stack + register int w; // bits before this table == (l * h) + uInt x[BMAX+1]; // bit offsets, then code stack + uInt *xp; // pointer into x + int y; // number of dummy codes added + uInt z; // number of entries in current table + + + // Generate counts for each bit length + p = c; +#define C0 *p++ = 0; +#define C2 C0 C0 C0 C0 +#define C4 C2 C2 C2 C2 + C4; p; // clear c[]--assume BMAX+1 is 16 + p = b; i = n; + do { + c[*p++]++; // assume all entries <= BMAX + } while (--i); + if (c[0] == n) // null input--all zero length codes + { + *t = (inflate_huft *)Z_NULL; + *m = 0; + return Z_OK; + } + + + // Find minimum and maximum length, bound *m by those + l = *m; + for (j = 1; j <= BMAX; j++) + if (c[j]) + break; + k = j; // minimum code length + if ((uInt)l < j) + l = j; + for (i = BMAX; i; i--) + if (c[i]) + break; + g = i; // maximum code length + if ((uInt)l > i) + l = i; + *m = l; + + + // Adjust last length count to fill out codes, if needed + for (y = 1 << j; j < i; j++, y <<= 1) + if ((y -= c[j]) < 0) + return Z_DATA_ERROR; + if ((y -= c[i]) < 0) + return Z_DATA_ERROR; + c[i] += y; + + + // Generate starting offsets into the value table for each length + x[1] = j = 0; + p = c + 1; xp = x + 2; + while (--i) { // note that i == g from above + *xp++ = (j += *p++); + } + + + // Make a table of values in order of bit lengths + p = b; i = 0; + do { + if ((j = *p++) != 0) + v[x[j]++] = i; + } while (++i < n); + n = x[g]; // set n to length of v + + + // Generate the Huffman codes and for each, make the table entries + x[0] = i = 0; // first Huffman code is zero + p = v; // grab values in bit order + h = -1; // no tables yet--level -1 + w = -l; // bits decoded == (l * h) + u[0] = (inflate_huft *)Z_NULL; // just to keep compilers happy + q = (inflate_huft *)Z_NULL; // ditto + z = 0; // ditto + + // go through the bit lengths (k already is bits in shortest code) + for (; k <= g; k++) + { + a = c[k]; + while (a--) + { + // here i is the Huffman code of length k bits for value *p + // make tables up to required level + while (k > w + l) + { + h++; + w += l; // previous table always l bits + + // compute minimum size table less than or equal to l bits + z = g - w; + z = z > (uInt)l ? l : z; // table size upper limit + if ((f = 1 << (j = k - w)) > a + 1) // try a k-w bit table + { // too few codes for k-w bit table + f -= a + 1; // deduct codes from patterns left + xp = c + k; + if (j < z) + while (++j < z) // try smaller tables up to z bits + { + if ((f <<= 1) <= *++xp) + break; // enough codes to use up j bits + f -= *xp; // else deduct codes from patterns + } + } + z = 1 << j; // table entries for j-bit table + + // allocate new table + if (*hn + z > MANY) // (note: doesn't matter for fixed) + return Z_MEM_ERROR; // not enough memory + u[h] = q = hp + *hn; + *hn += z; + + // connect to last table, if there is one + if (h) + { + x[h] = i; // save pattern for backing up + r.bits = (Byte)l; // bits to dump before this table + r.exop = (Byte)j; // bits in this table + j = i >> (w - l); + r.base = (uInt)(q - u[h-1] - j); // offset to this table + u[h-1][j] = r; // connect to last table + } + else + *t = q; // first table is returned result + } + + // set up table entry in r + r.bits = (Byte)(k - w); + if (p >= v + n) + r.exop = 128 + 64; // out of values--invalid code + else if (*p < s) + { + r.exop = (Byte)(*p < 256 ? 0 : 32 + 64); // 256 is end-of-block + r.base = *p++; // simple code is just the value + } + else + { + r.exop = (Byte)(e[*p - s] + 16 + 64);// non-simple--look up in lists + r.base = d[*p++ - s]; + } + + // fill code-like entries with r + f = 1 << (k - w); + for (j = i >> w; j < z; j += f) + q[j] = r; + + // backwards increment the k-bit code i + for (j = 1 << (k - 1); i & j; j >>= 1) + i ^= j; + i ^= j; + + // backup over finished tables + mask = (1 << w) - 1; // needed on HP, cc -O bug + while ((i & mask) != x[h]) + { + h--; // don't need to update q + w -= l; + mask = (1 << w) - 1; + } + } + } + + + // Return Z_BUF_ERROR if we were given an incomplete table + return y != 0 && g != 1 ? Z_BUF_ERROR : Z_OK; +} + + +int inflate_trees_bits( +uInt *c, // 19 code lengths +uInt *bb, // bits tree desired/actual depth +inflate_huft * *tb, // bits tree result +inflate_huft *hp, // space for trees +z_streamp z) // for messages +{ + int r; + uInt hn = 0; // hufts used in space + uInt *v; // work area for huft_build + + if ((v = (uInt*)ZALLOC(z, 19, sizeof(uInt))) == Z_NULL) + return Z_MEM_ERROR; + r = huft_build(c, 19, 19, (uInt*)Z_NULL, (uInt*)Z_NULL, + tb, bb, hp, &hn, v); + if (r == Z_DATA_ERROR) + z->msg = (char*)"oversubscribed dynamic bit lengths tree"; + else if (r == Z_BUF_ERROR || *bb == 0) + { + z->msg = (char*)"incomplete dynamic bit lengths tree"; + r = Z_DATA_ERROR; + } + ZFREE(z, v); + return r; +} + + +int inflate_trees_dynamic( +uInt nl, // number of literal/length codes +uInt nd, // number of distance codes +uInt *c, // that many (total) code lengths +uInt *bl, // literal desired/actual bit depth +uInt *bd, // distance desired/actual bit depth +inflate_huft * *tl, // literal/length tree result +inflate_huft * *td, // distance tree result +inflate_huft *hp, // space for trees +z_streamp z) // for messages +{ + int r; + uInt hn = 0; // hufts used in space + uInt *v; // work area for huft_build + + // allocate work area + if ((v = (uInt*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL) + return Z_MEM_ERROR; + + // build literal/length tree + r = huft_build(c, nl, 257, cplens, cplext, tl, bl, hp, &hn, v); + if (r != Z_OK || *bl == 0) + { + if (r == Z_DATA_ERROR) + z->msg = (char*)"oversubscribed literal/length tree"; + else if (r != Z_MEM_ERROR) + { + z->msg = (char*)"incomplete literal/length tree"; + r = Z_DATA_ERROR; + } + ZFREE(z, v); + return r; + } + + // build distance tree + r = huft_build(c + nl, nd, 0, cpdist, cpdext, td, bd, hp, &hn, v); + if (r != Z_OK || (*bd == 0 && nl > 257)) + { + if (r == Z_DATA_ERROR) + z->msg = (char*)"oversubscribed distance tree"; + else if (r == Z_BUF_ERROR) { + z->msg = (char*)"incomplete distance tree"; + r = Z_DATA_ERROR; + } + else if (r != Z_MEM_ERROR) + { + z->msg = (char*)"empty distance tree with lengths"; + r = Z_DATA_ERROR; + } + ZFREE(z, v); + return r; + } + + // done + ZFREE(z, v); + return Z_OK; +} + + + + + +int inflate_trees_fixed( +uInt *bl, // literal desired/actual bit depth +uInt *bd, // distance desired/actual bit depth +const inflate_huft * * tl, // literal/length tree result +const inflate_huft * *td, // distance tree result +z_streamp ) // for memory allocation +{ + *bl = fixed_bl; + *bd = fixed_bd; + *tl = fixed_tl; + *td = fixed_td; + return Z_OK; +} + + +// inffast.c -- process literals and length/distance pairs fast +// Copyright (C) 1995-1998 Mark Adler +// For conditions of distribution and use, see copyright notice in zlib.h +// + + +//struct inflate_codes_state {int dummy;}; // for buggy compilers + + +// macros for bit input with no checking and for returning unused bytes +#define GRABBITS(j) {while(k<(j)){b|=((uLong)NEXTBYTE)<avail_in-n;c=(k>>3)>3:c;n+=c;p-=c;k-=c<<3;} + +// Called with number of bytes left to write in window at least 258 +// (the maximum string length) and number of input bytes available +// at least ten. The ten bytes are six bytes for the longest length/ +// distance pair plus four bytes for overloading the bit buffer. + +int inflate_fast( +uInt bl, uInt bd, +const inflate_huft *tl, +const inflate_huft *td, // need separate declaration for Borland C++ +inflate_blocks_statef *s, +z_streamp z) +{ + const inflate_huft *t; // temporary pointer + uInt e; // extra bits or operation + uLong b; // bit buffer + uInt k; // bits in bit buffer + Byte *p; // input data pointer + uInt n; // bytes available there + Byte *q; // output window write pointer + uInt m; // bytes to end of window or read pointer + uInt ml; // mask for literal/length tree + uInt md; // mask for distance tree + uInt c; // bytes to copy + uInt d; // distance back to copy from + Byte *r; // copy source pointer + + // load input, output, bit values + LOAD + + // initialize masks + ml = inflate_mask[bl]; + md = inflate_mask[bd]; + + // do until not enough input or output space for fast loop + do { // assume called with m >= 258 && n >= 10 + // get literal/length code + GRABBITS(20) // max bits for literal/length code + if ((e = (t = tl + ((uInt)b & ml))->exop) == 0) + { + DUMPBITS(t->bits) + Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ? + "inflate: * literal '%c'\n" : + "inflate: * literal 0x%02x\n", t->base)); + *q++ = (Byte)t->base; + m--; + continue; + } + for (;;) { + DUMPBITS(t->bits) + if (e & 16) + { + // get extra bits for length + e &= 15; + c = t->base + ((uInt)b & inflate_mask[e]); + DUMPBITS(e) + Tracevv((stderr, "inflate: * length %u\n", c)); + + // decode distance base of block to copy + GRABBITS(15); // max bits for distance code + e = (t = td + ((uInt)b & md))->exop; + for (;;) { + DUMPBITS(t->bits) + if (e & 16) + { + // get extra bits to add to distance base + e &= 15; + GRABBITS(e) // get extra bits (up to 13) + d = t->base + ((uInt)b & inflate_mask[e]); + DUMPBITS(e) + Tracevv((stderr, "inflate: * distance %u\n", d)); + + // do the copy + m -= c; + if ((uInt)(q - s->window) >= d) // offset before dest + { // just copy + r = q - d; + *q++ = *r++; c--; // minimum count is three, + *q++ = *r++; c--; // so unroll loop a little + } + else // else offset after destination + { + e = d - (uInt)(q - s->window); // bytes from offset to end + r = s->end - e; // pointer to offset + if (c > e) // if source crosses, + { + c -= e; // copy to end of window + do { + *q++ = *r++; + } while (--e); + r = s->window; // copy rest from start of window + } + } + do { // copy all or what's left + *q++ = *r++; + } while (--c); + break; + } + else if ((e & 64) == 0) + { + t += t->base; + e = (t += ((uInt)b & inflate_mask[e]))->exop; + } + else + { + z->msg = (char*)"invalid distance code"; + UNGRAB + UPDATE + return Z_DATA_ERROR; + } + }; + break; + } + if ((e & 64) == 0) + { + t += t->base; + if ((e = (t += ((uInt)b & inflate_mask[e]))->exop) == 0) + { + DUMPBITS(t->bits) + Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ? + "inflate: * literal '%c'\n" : + "inflate: * literal 0x%02x\n", t->base)); + *q++ = (Byte)t->base; + m--; + break; + } + } + else if (e & 32) + { + Tracevv((stderr, "inflate: * end of block\n")); + UNGRAB + UPDATE + return Z_STREAM_END; + } + else + { + z->msg = (char*)"invalid literal/length code"; + UNGRAB + UPDATE + return Z_DATA_ERROR; + } + }; + } while (m >= 258 && n >= 10); + + // not enough input or output--restore pointers and return + UNGRAB + UPDATE + return Z_OK; +} + + + + + + +// crc32.c -- compute the CRC-32 of a data stream +// Copyright (C) 1995-1998 Mark Adler +// For conditions of distribution and use, see copyright notice in zlib.h + +// @(#) $Id$ + + + + + + +// Table of CRC-32's of all single-byte values (made by make_crc_table) +const uLong crc_table[256] = { + 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, + 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, + 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, + 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, + 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, + 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, + 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, + 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, + 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, + 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL, + 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, + 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, + 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L, + 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, + 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, + 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, + 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, + 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L, + 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, + 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, + 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL, + 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, + 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L, + 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, + 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L, + 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L, + 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L, + 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L, + 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L, + 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL, + 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL, + 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L, + 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L, + 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL, + 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL, + 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L, + 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL, + 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L, + 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL, + 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L, + 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL, + 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L, + 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L, + 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL, + 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L, + 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L, + 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L, + 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L, + 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L, + 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L, + 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL, + 0x2d02ef8dL +}; + +const uLong * get_crc_table() +{ return (const uLong *)crc_table; +} + +#define CRC_DO1(buf) crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8); +#define CRC_DO2(buf) CRC_DO1(buf); CRC_DO1(buf); +#define CRC_DO4(buf) CRC_DO2(buf); CRC_DO2(buf); +#define CRC_DO8(buf) CRC_DO4(buf); CRC_DO4(buf); + +uLong ucrc32(uLong crc, const Byte *buf, uInt len) +{ if (buf == Z_NULL) return 0L; + crc = crc ^ 0xffffffffL; + while (len >= 8) {CRC_DO8(buf); len -= 8;} + if (len) do {CRC_DO1(buf);} while (--len); + return crc ^ 0xffffffffL; +} + + +// adler32.c -- compute the Adler-32 checksum of a data stream +// Copyright (C) 1995-1998 Mark Adler +// For conditions of distribution and use, see copyright notice in zlib.h + +// @(#) $Id$ + + +#define BASE 65521L // largest prime smaller than 65536 +#define NMAX 5552 +// NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 + +#define AD_DO1(buf,i) {s1 += buf[i]; s2 += s1;} +#define AD_DO2(buf,i) AD_DO1(buf,i); AD_DO1(buf,i+1); +#define AD_DO4(buf,i) AD_DO2(buf,i); AD_DO2(buf,i+2); +#define AD_DO8(buf,i) AD_DO4(buf,i); AD_DO4(buf,i+4); +#define AD_DO16(buf) AD_DO8(buf,0); AD_DO8(buf,8); + +// ========================================================================= +uLong adler32(uLong adler, const Byte *buf, uInt len) +{ + unsigned long s1 = adler & 0xffff; + unsigned long s2 = (adler >> 16) & 0xffff; + int k; + + if (buf == Z_NULL) return 1L; + + while (len > 0) { + k = len < NMAX ? len : NMAX; + len -= k; + while (k >= 16) { + AD_DO16(buf); + buf += 16; + k -= 16; + } + if (k != 0) do { + s1 += *buf++; + s2 += s1; + } while (--k); + s1 %= BASE; + s2 %= BASE; + } + return (s2 << 16) | s1; +} + + + +// zutil.c -- target dependent utility functions for the compression library +// Copyright (C) 1995-1998 Jean-loup Gailly. +// For conditions of distribution and use, see copyright notice in zlib.h +// @(#) $Id$ + + + + + + +const char * zlibVersion() +{ + return ZLIB_VERSION; +} + +// exported to allow conversion of error code to string for compress() and +// uncompress() +const char * zError(int err) +{ return ERR_MSG(err); +} + + + + +voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) +{ + if (opaque) items += size - size; // make compiler happy + return (voidpf)calloc(items, size); +} + +void zcfree (voidpf opaque, voidpf ptr) +{ + zfree(ptr); + if (opaque) return; // make compiler happy +} + + + +// inflate.c -- zlib interface to inflate modules +// Copyright (C) 1995-1998 Mark Adler +// For conditions of distribution and use, see copyright notice in zlib.h + +//struct inflate_blocks_state {int dummy;}; // for buggy compilers + +typedef enum { + IM_METHOD, // waiting for method byte + IM_FLAG, // waiting for flag byte + IM_DICT4, // four dictionary check bytes to go + IM_DICT3, // three dictionary check bytes to go + IM_DICT2, // two dictionary check bytes to go + IM_DICT1, // one dictionary check byte to go + IM_DICT0, // waiting for inflateSetDictionary + IM_BLOCKS, // decompressing blocks + IM_CHECK4, // four check bytes to go + IM_CHECK3, // three check bytes to go + IM_CHECK2, // two check bytes to go + IM_CHECK1, // one check byte to go + IM_DONE, // finished check, done + IM_BAD} // got an error--stay here +inflate_mode; + +// inflate private state +struct internal_state { + + // mode + inflate_mode mode; // current inflate mode + + // mode dependent information + union { + uInt method; // if IM_FLAGS, method byte + struct { + uLong was; // computed check value + uLong need; // stream check value + } check; // if CHECK, check values to compare + uInt marker; // if IM_BAD, inflateSync's marker bytes count + } sub; // submode + + // mode independent information + int nowrap; // flag for no wrapper + uInt wbits; // log2(window size) (8..15, defaults to 15) + inflate_blocks_statef + *blocks; // current inflate_blocks state + +}; + +int inflateReset(z_streamp z) +{ + if (z == Z_NULL || z->state == Z_NULL) + return Z_STREAM_ERROR; + z->total_in = z->total_out = 0; + z->msg = Z_NULL; + z->state->mode = z->state->nowrap ? IM_BLOCKS : IM_METHOD; + inflate_blocks_reset(z->state->blocks, z, Z_NULL); + Tracev((stderr, "inflate: reset\n")); + return Z_OK; +} + +int inflateEnd(z_streamp z) +{ + if (z == Z_NULL || z->state == Z_NULL || z->zfree == Z_NULL) + return Z_STREAM_ERROR; + if (z->state->blocks != Z_NULL) + inflate_blocks_free(z->state->blocks, z); + ZFREE(z, z->state); + z->state = Z_NULL; + Tracev((stderr, "inflate: end\n")); + return Z_OK; +} + + +int inflateInit2(z_streamp z) +{ const char *version = ZLIB_VERSION; int stream_size = sizeof(z_stream); + if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || stream_size != sizeof(z_stream)) return Z_VERSION_ERROR; + + int w = -15; // MAX_WBITS: 32K LZ77 window. + // Warning: reducing MAX_WBITS makes minigzip unable to extract .gz files created by gzip. + // The memory requirements for deflate are (in bytes): + // (1 << (windowBits+2)) + (1 << (memLevel+9)) + // that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) + // plus a few kilobytes for small objects. For example, if you want to reduce + // the default memory requirements from 256K to 128K, compile with + // make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" + // Of course this will generally degrade compression (there's no free lunch). + // + // The memory requirements for inflate are (in bytes) 1 << windowBits + // that is, 32K for windowBits=15 (default value) plus a few kilobytes + // for small objects. + + // initialize state + if (z == Z_NULL) return Z_STREAM_ERROR; + z->msg = Z_NULL; + if (z->zalloc == Z_NULL) + { + z->zalloc = zcalloc; + z->opaque = (voidpf)0; + } + if (z->zfree == Z_NULL) z->zfree = zcfree; + if ((z->state = (struct internal_state *) + ZALLOC(z,1,sizeof(struct internal_state))) == Z_NULL) + return Z_MEM_ERROR; + z->state->blocks = Z_NULL; + + // handle undocumented nowrap option (no zlib header or check) + z->state->nowrap = 0; + if (w < 0) + { + w = - w; + z->state->nowrap = 1; + } + + // set window size + if (w < 8 || w > 15) + { + inflateEnd(z); + return Z_STREAM_ERROR; + } + z->state->wbits = (uInt)w; + + // create inflate_blocks state + if ((z->state->blocks = + inflate_blocks_new(z, z->state->nowrap ? Z_NULL : adler32, (uInt)1 << w)) + == Z_NULL) + { + inflateEnd(z); + return Z_MEM_ERROR; + } + Tracev((stderr, "inflate: allocated\n")); + + // reset state + inflateReset(z); + return Z_OK; +} + + + +#define IM_NEEDBYTE {if(z->avail_in==0)return r;r=f;} +#define IM_NEXTBYTE (z->avail_in--,z->total_in++,*z->next_in++) + +int inflate(z_streamp z, int f) +{ + int r; + uInt b; + + if (z == Z_NULL || z->state == Z_NULL || z->next_in == Z_NULL) + return Z_STREAM_ERROR; + f = f == Z_FINISH ? Z_BUF_ERROR : Z_OK; + r = Z_BUF_ERROR; + for (;;) switch (z->state->mode) + { + case IM_METHOD: + IM_NEEDBYTE + if (((z->state->sub.method = IM_NEXTBYTE) & 0xf) != Z_DEFLATED) + { + z->state->mode = IM_BAD; + z->msg = (char*)"unknown compression method"; + z->state->sub.marker = 5; // can't try inflateSync + break; + } + if ((z->state->sub.method >> 4) + 8 > z->state->wbits) + { + z->state->mode = IM_BAD; + z->msg = (char*)"invalid window size"; + z->state->sub.marker = 5; // can't try inflateSync + break; + } + z->state->mode = IM_FLAG; + case IM_FLAG: + IM_NEEDBYTE + b = IM_NEXTBYTE; + if (((z->state->sub.method << 8) + b) % 31) + { + z->state->mode = IM_BAD; + z->msg = (char*)"incorrect header check"; + z->state->sub.marker = 5; // can't try inflateSync + break; + } + Tracev((stderr, "inflate: zlib header ok\n")); + if (!(b & PRESET_DICT)) + { + z->state->mode = IM_BLOCKS; + break; + } + z->state->mode = IM_DICT4; + case IM_DICT4: + IM_NEEDBYTE + z->state->sub.check.need = (uLong)IM_NEXTBYTE << 24; + z->state->mode = IM_DICT3; + case IM_DICT3: + IM_NEEDBYTE + z->state->sub.check.need += (uLong)IM_NEXTBYTE << 16; + z->state->mode = IM_DICT2; + case IM_DICT2: + IM_NEEDBYTE + z->state->sub.check.need += (uLong)IM_NEXTBYTE << 8; + z->state->mode = IM_DICT1; + case IM_DICT1: + IM_NEEDBYTE; r; + z->state->sub.check.need += (uLong)IM_NEXTBYTE; + z->adler = z->state->sub.check.need; + z->state->mode = IM_DICT0; + return Z_NEED_DICT; + case IM_DICT0: + z->state->mode = IM_BAD; + z->msg = (char*)"need dictionary"; + z->state->sub.marker = 0; // can try inflateSync + return Z_STREAM_ERROR; + case IM_BLOCKS: + r = inflate_blocks(z->state->blocks, z, r); + if (r == Z_DATA_ERROR) + { + z->state->mode = IM_BAD; + z->state->sub.marker = 0; // can try inflateSync + break; + } + if (r == Z_OK) + r = f; + if (r != Z_STREAM_END) + return r; + r = f; + inflate_blocks_reset(z->state->blocks, z, &z->state->sub.check.was); + if (z->state->nowrap) + { + z->state->mode = IM_DONE; + break; + } + z->state->mode = IM_CHECK4; + case IM_CHECK4: + IM_NEEDBYTE + z->state->sub.check.need = (uLong)IM_NEXTBYTE << 24; + z->state->mode = IM_CHECK3; + case IM_CHECK3: + IM_NEEDBYTE + z->state->sub.check.need += (uLong)IM_NEXTBYTE << 16; + z->state->mode = IM_CHECK2; + case IM_CHECK2: + IM_NEEDBYTE + z->state->sub.check.need += (uLong)IM_NEXTBYTE << 8; + z->state->mode = IM_CHECK1; + case IM_CHECK1: + IM_NEEDBYTE + z->state->sub.check.need += (uLong)IM_NEXTBYTE; + + if (z->state->sub.check.was != z->state->sub.check.need) + { + z->state->mode = IM_BAD; + z->msg = (char*)"incorrect data check"; + z->state->sub.marker = 5; // can't try inflateSync + break; + } + Tracev((stderr, "inflate: zlib check ok\n")); + z->state->mode = IM_DONE; + case IM_DONE: + return Z_STREAM_END; + case IM_BAD: + return Z_DATA_ERROR; + default: + return Z_STREAM_ERROR; + } +} + + + +#ifdef _UNICODE + +static int GetAnsiFileName(LPCWSTR name, char * buf, int nBufSize) +{ + memset(buf, 0, nBufSize); + + int n = WideCharToMultiByte(CP_ACP, // code page + 0, // performance and mapping flags + name, // wide-character string + -1, // number of chars in string + buf, // buffer for new string + nBufSize, // size of buffer + NULL, // default for unmappable chars + NULL); // set when default char used + return n; +} + +static int GetUnicodeFileName(const char * name, LPWSTR buf, int nBufSize) +{ + memset(buf, 0, nBufSize*sizeof(TCHAR)); + + int n = MultiByteToWideChar(CP_ACP, // code page + 0, // character-type options + name, // string to map + -1, // number of bytes in string + buf, // wide-character buffer + nBufSize); // size of buffer + + return n; +} + +#endif + + +// unzip.c -- IO on .zip files using zlib +// Version 0.15 beta, Mar 19th, 1998, +// Read unzip.h for more info + + + + +#define UNZ_BUFSIZE (16384) +#define UNZ_MAXFILENAMEINZIP (256) +#define SIZECENTRALDIRITEM (0x2e) +#define SIZEZIPLOCALHEADER (0x1e) + + + + +const char unz_copyright[] = " ";//unzip 0.15 Copyright 1998 Gilles Vollant "; + +// unz_file_info_interntal contain internal info about a file in zipfile +typedef struct unz_file_info_internal_s +{ + uLong offset_curfile;// relative offset of local header 4 bytes +} unz_file_info_internal; + + +typedef struct +{ bool is_handle; // either a handle or memory + bool canseek; + // for handles: + HANDLE h; bool herr; unsigned long initial_offset; + // for memory: + void *buf; unsigned int len,pos; // if it's a memory block +} LUFILE; + + +LUFILE *lufopen(void *z,unsigned int len,DWORD flags,ZRESULT *err) +{ + if (flags!=ZIP_HANDLE && flags!=ZIP_FILENAME && flags!=ZIP_MEMORY) + { + *err=ZR_ARGS; + return NULL; + } + // + HANDLE h=0; bool canseek=false; *err=ZR_OK; + if (flags==ZIP_HANDLE||flags==ZIP_FILENAME) + { + if (flags==ZIP_HANDLE) + { + HANDLE hf = z; + + BOOL res = DuplicateHandle(GetCurrentProcess(),hf,GetCurrentProcess(),&h,0,FALSE,DUPLICATE_SAME_ACCESS); + + if (!res) + { + *err=ZR_NODUPH; + return NULL; + } + } + else + { + h = CreateFile((const TCHAR *)z, GENERIC_READ, FILE_SHARE_READ, + NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + + if (h == INVALID_HANDLE_VALUE) + { + *err = ZR_NOFILE; + return NULL; + } + } + DWORD type = GetFileType(h); + canseek = (type==FILE_TYPE_DISK); + } + LUFILE *lf = new LUFILE; + if (flags==ZIP_HANDLE||flags==ZIP_FILENAME) + { + lf->is_handle=true; + lf->canseek=canseek; + lf->h=h; lf->herr=false; + lf->initial_offset=0; + if (canseek) + lf->initial_offset = SetFilePointer(h,0,NULL,FILE_CURRENT); + } + else + { + lf->is_handle=false; + lf->canseek=true; + lf->buf=z; + lf->len=len; + lf->pos=0; + lf->initial_offset=0; + } + *err=ZR_OK; + return lf; +} + + +int lufclose(LUFILE *stream) +{ if (stream==NULL) return EOF; + if (stream->is_handle) CloseHandle(stream->h); + delete stream; + return 0; +} + +int luferror(LUFILE *stream) +{ if (stream->is_handle && stream->herr) return 1; + else return 0; +} + +long int luftell(LUFILE *stream) +{ if (stream->is_handle && stream->canseek) return SetFilePointer(stream->h,0,NULL,FILE_CURRENT)-stream->initial_offset; + else if (stream->is_handle) return 0; + else return stream->pos; +} + +int lufseek(LUFILE *stream, long offset, int whence) +{ if (stream->is_handle && stream->canseek) + { if (whence==SEEK_SET) SetFilePointer(stream->h,stream->initial_offset+offset,0,FILE_BEGIN); + else if (whence==SEEK_CUR) SetFilePointer(stream->h,offset,NULL,FILE_CURRENT); + else if (whence==SEEK_END) SetFilePointer(stream->h,offset,NULL,FILE_END); + else return 19; // EINVAL + return 0; + } + else if (stream->is_handle) return 29; // ESPIPE + else + { if (whence==SEEK_SET) stream->pos=offset; + else if (whence==SEEK_CUR) stream->pos+=offset; + else if (whence==SEEK_END) stream->pos=stream->len+offset; + return 0; + } +} + + +size_t lufread(void *ptr,size_t size,size_t n,LUFILE *stream) +{ unsigned int toread = (unsigned int)(size*n); + if (stream->is_handle) + { DWORD red; BOOL res = ReadFile(stream->h,ptr,toread,&red,NULL); + if (!res) stream->herr=true; + return red/size; + } + if (stream->pos+toread > stream->len) toread = stream->len-stream->pos; + memcpy(ptr, (char*)stream->buf + stream->pos, toread); DWORD red = toread; + stream->pos += red; + return red/size; +} + + + + +// file_in_zip_read_info_s contain internal information about a file in zipfile, +// when reading and decompress it +typedef struct +{ + char *read_buffer; // internal buffer for compressed data + z_stream stream; // zLib stream structure for inflate + + uLong pos_in_zipfile; // position in byte on the zipfile, for fseek + uLong stream_initialised; // flag set if stream structure is initialised + + uLong offset_local_extrafield;// offset of the local extra field + uInt size_local_extrafield;// size of the local extra field + uLong pos_local_extrafield; // position in the local extra field in read + + uLong crc32; // crc32 of all data uncompressed + uLong crc32_wait; // crc32 we must obtain after decompress all + uLong rest_read_compressed; // number of byte to be decompressed + uLong rest_read_uncompressed;//number of byte to be obtained after decomp + LUFILE* file; // io structore of the zipfile + uLong compression_method; // compression method (0==store) + uLong byte_before_the_zipfile;// byte before the zipfile, (>0 for sfx) +} file_in_zip_read_info_s; + + +// unz_s contain internal information about the zipfile +typedef struct +{ + LUFILE* file; // io structore of the zipfile + unz_global_info gi; // public global information + uLong byte_before_the_zipfile;// byte before the zipfile, (>0 for sfx) + uLong num_file; // number of the current file in the zipfile + uLong pos_in_central_dir; // pos of the current file in the central dir + uLong current_file_ok; // flag about the usability of the current file + uLong central_pos; // position of the beginning of the central dir + + uLong size_central_dir; // size of the central directory + uLong offset_central_dir; // offset of start of central directory with respect to the starting disk number + + unz_file_info cur_file_info; // public info about the current file in zip + unz_file_info_internal cur_file_info_internal; // private info about it + file_in_zip_read_info_s* pfile_in_zip_read; // structure about the current file if we are decompressing it +} unz_s, *unzFile; + + +int unzStringFileNameCompare (const char* fileName1,const char* fileName2,int iCaseSensitivity); +// Compare two filename (fileName1,fileName2). + +z_off_t unztell (unzFile file); +// Give the current position in uncompressed data + +int unzeof (unzFile file); +// return 1 if the end of file was reached, 0 elsewhere + +int unzGetLocalExtrafield (unzFile file, voidp buf, unsigned len); +// Read extra field from the current file (opened by unzOpenCurrentFile) +// This is the local-header version of the extra field (sometimes, there is +// more info in the local-header version than in the central-header) +// +// if buf==NULL, it return the size of the local extra field +// +// if buf!=NULL, len is the size of the buffer, the extra header is copied in +// buf. +// the return value is the number of bytes copied in buf, or (if <0) +// the error code + + + +// =========================================================================== +// Read a byte from a gz_stream; update next_in and avail_in. Return EOF +// for end of file. +// IN assertion: the stream s has been sucessfully opened for reading. + +int unzlocal_getByte(LUFILE *fin,int *pi) +{ unsigned char c; + int err = (int)lufread(&c, 1, 1, fin); + if (err==1) + { *pi = (int)c; + return UNZ_OK; + } + else + { if (luferror(fin)) return UNZ_ERRNO; + else return UNZ_EOF; + } +} + + +// =========================================================================== +// Reads a long in LSB order from the given gz_stream. Sets +int unzlocal_getShort (LUFILE *fin,uLong *pX) +{ + uLong x ; + int i; + int err; + + err = unzlocal_getByte(fin,&i); + x = (uLong)i; + + if (err==UNZ_OK) + err = unzlocal_getByte(fin,&i); + x += ((uLong)i)<<8; + + if (err==UNZ_OK) + *pX = x; + else + *pX = 0; + return err; +} + +int unzlocal_getLong (LUFILE *fin,uLong *pX) +{ + uLong x ; + int i; + int err; + + err = unzlocal_getByte(fin,&i); + x = (uLong)i; + + if (err==UNZ_OK) + err = unzlocal_getByte(fin,&i); + x += ((uLong)i)<<8; + + if (err==UNZ_OK) + err = unzlocal_getByte(fin,&i); + x += ((uLong)i)<<16; + + if (err==UNZ_OK) + err = unzlocal_getByte(fin,&i); + x += ((uLong)i)<<24; + + if (err==UNZ_OK) + *pX = x; + else + *pX = 0; + return err; +} + + +// My own strcmpi / strcasecmp +int strcmpcasenosensitive_internal (const char* fileName1,const char *fileName2) +{ + for (;;) + { + char c1=*(fileName1++); + char c2=*(fileName2++); + if ((c1>='a') && (c1<='z')) + c1 -= (char)0x20; + if ((c2>='a') && (c2<='z')) + c2 -= (char)0x20; + if (c1=='\0') + return ((c2=='\0') ? 0 : -1); + if (c2=='\0') + return 1; + if (c1c2) + return 1; + } +} + + + + +// +// Compare two filename (fileName1,fileName2). +// If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) +// If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi or strcasecmp) +// +int unzStringFileNameCompare (const char*fileName1,const char*fileName2,int iCaseSensitivity) +{ if (iCaseSensitivity==1) return strcmp(fileName1,fileName2); + else return strcmpcasenosensitive_internal(fileName1,fileName2); +} + +#define BUFREADCOMMENT (0x400) + + +// Locate the Central directory of a zipfile (at the end, just before +// the global comment) +uLong unzlocal_SearchCentralDir(LUFILE *fin) +{ if (lufseek(fin,0,SEEK_END) != 0) return 0; + uLong uSizeFile = luftell(fin); + + uLong uMaxBack=0xffff; // maximum size of global comment + if (uMaxBack>uSizeFile) uMaxBack = uSizeFile; + + unsigned char *buf = (unsigned char*)zmalloc(BUFREADCOMMENT+4); + if (buf==NULL) return 0; + uLong uPosFound=0; + + uLong uBackRead = 4; + while (uBackReaduMaxBack) uBackRead = uMaxBack; + else uBackRead+=BUFREADCOMMENT; + uReadPos = uSizeFile-uBackRead ; + uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? (BUFREADCOMMENT+4) : (uSizeFile-uReadPos); + if (lufseek(fin,uReadPos,SEEK_SET)!=0) break; + if (lufread(buf,(uInt)uReadSize,1,fin)!=1) break; + for (i=(int)uReadSize-3; (i--)>0;) + { if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) + { uPosFound = uReadPos+i; break; + } + } + if (uPosFound!=0) break; + } + if (buf) zfree(buf); + return uPosFound; +} + + +int unzGoToFirstFile (unzFile file); +int unzCloseCurrentFile (unzFile file); + +// Open a Zip file. +// If the zipfile cannot be opened (file don't exist or in not valid), return NULL. +// Otherwise, the return value is a unzFile Handle, usable with other unzip functions +unzFile unzOpenInternal(LUFILE *fin) +{ + zopenerror = ZR_OK; //+++1.2 + if (fin==NULL) { zopenerror = ZR_ARGS; return NULL; } //+++1.2 + if (unz_copyright[0]!=' ') {lufclose(fin); zopenerror = ZR_CORRUPT; return NULL; } //+++1.2 + + int err=UNZ_OK; + unz_s us; + uLong central_pos,uL; + central_pos = unzlocal_SearchCentralDir(fin); + if (central_pos==0) err=UNZ_ERRNO; + if (lufseek(fin,central_pos,SEEK_SET)!=0) err=UNZ_ERRNO; + // the signature, already checked + if (unzlocal_getLong(fin,&uL)!=UNZ_OK) err=UNZ_ERRNO; + // number of this disk + uLong number_disk; // number of the current dist, used for spanning ZIP, unsupported, always 0 + if (unzlocal_getShort(fin,&number_disk)!=UNZ_OK) err=UNZ_ERRNO; + // number of the disk with the start of the central directory + uLong number_disk_with_CD; // number the the disk with central dir, used for spaning ZIP, unsupported, always 0 + if (unzlocal_getShort(fin,&number_disk_with_CD)!=UNZ_OK) err=UNZ_ERRNO; + // total number of entries in the central dir on this disk + if (unzlocal_getShort(fin,&us.gi.number_entry)!=UNZ_OK) err=UNZ_ERRNO; + // total number of entries in the central dir + uLong number_entry_CD; // total number of entries in the central dir (same than number_entry on nospan) + if (unzlocal_getShort(fin,&number_entry_CD)!=UNZ_OK) err=UNZ_ERRNO; + if ((number_entry_CD!=us.gi.number_entry) || (number_disk_with_CD!=0) || (number_disk!=0)) err=UNZ_BADZIPFILE; + // size of the central directory + if (unzlocal_getLong(fin,&us.size_central_dir)!=UNZ_OK) err=UNZ_ERRNO; + // offset of start of central directory with respect to the starting disk number + if (unzlocal_getLong(fin,&us.offset_central_dir)!=UNZ_OK) err=UNZ_ERRNO; + // zipfile comment length + if (unzlocal_getShort(fin,&us.gi.size_comment)!=UNZ_OK) err=UNZ_ERRNO; + if ((central_pos+fin->initial_offsetinitial_offset - (us.offset_central_dir+us.size_central_dir); + us.central_pos = central_pos; + us.pfile_in_zip_read = NULL; + fin->initial_offset = 0; // since the zipfile itself is expected to handle this + + unz_s *s = (unz_s*)zmalloc(sizeof(unz_s)); + *s=us; + unzGoToFirstFile((unzFile)s); + return (unzFile)s; +} + + + +// Close a ZipFile opened with unzipOpen. +// If there is files inside the .Zip opened with unzipOpenCurrentFile (see later), +// these files MUST be closed with unzipCloseCurrentFile before call unzipClose. +// return UNZ_OK if there is no problem. +int unzClose (unzFile file) +{ + unz_s* s; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + + if (s->pfile_in_zip_read!=NULL) + unzCloseCurrentFile(file); + + lufclose(s->file); + if (s) zfree(s); // unused s=0; + return UNZ_OK; +} + + +// Write info about the ZipFile in the *pglobal_info structure. +// No preparation of the structure is needed +// return UNZ_OK if there is no problem. +int unzGetGlobalInfo (unzFile file,unz_global_info *pglobal_info) +{ + unz_s* s; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + *pglobal_info=s->gi; + return UNZ_OK; +} + + +// Translate date/time from Dos format to tm_unz (readable more easilty) +void unzlocal_DosDateToTmuDate (uLong ulDosDate, tm_unz* ptm) +{ + uLong uDate; + uDate = (uLong)(ulDosDate>>16); + ptm->tm_mday = (uInt)(uDate&0x1f) ; + ptm->tm_mon = (uInt)((((uDate)&0x1E0)/0x20)-1) ; + ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ; + + ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800); + ptm->tm_min = (uInt) ((ulDosDate&0x7E0)/0x20) ; + ptm->tm_sec = (uInt) (2*(ulDosDate&0x1f)) ; +} + +// Get Info about the current file in the zipfile, with internal only info +int unzlocal_GetCurrentFileInfoInternal (unzFile file, + unz_file_info *pfile_info, + unz_file_info_internal + *pfile_info_internal, + char *szFileName, + uLong fileNameBufferSize, + void *extraField, + uLong extraFieldBufferSize, + char *szComment, + uLong commentBufferSize); + +int unzlocal_GetCurrentFileInfoInternal (unzFile file, unz_file_info *pfile_info, + unz_file_info_internal *pfile_info_internal, char *szFileName, + uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, + char *szComment, uLong commentBufferSize) +{ + unz_s* s; + unz_file_info file_info; + unz_file_info_internal file_info_internal; + int err=UNZ_OK; + uLong uMagic; + long lSeek=0; + + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + if (lufseek(s->file,s->pos_in_central_dir+s->byte_before_the_zipfile,SEEK_SET)!=0) + err=UNZ_ERRNO; + + + // we check the magic + if (err==UNZ_OK) + if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) + err=UNZ_ERRNO; + else if (uMagic!=0x02014b50) + err=UNZ_BADZIPFILE; + + if (unzlocal_getShort(s->file,&file_info.version) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&file_info.version_needed) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&file_info.flag) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&file_info.compression_method) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(s->file,&file_info.dosDate) != UNZ_OK) + err=UNZ_ERRNO; + + unzlocal_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date); + + if (unzlocal_getLong(s->file,&file_info.crc) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(s->file,&file_info.compressed_size) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(s->file,&file_info.uncompressed_size) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&file_info.size_filename) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&file_info.size_file_extra) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&file_info.size_file_comment) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&file_info.disk_num_start) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&file_info.internal_fa) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(s->file,&file_info.external_fa) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(s->file,&file_info_internal.offset_curfile) != UNZ_OK) + err=UNZ_ERRNO; + + lSeek+=file_info.size_filename; + if ((err==UNZ_OK) && (szFileName!=NULL)) + { + uLong uSizeRead ; + if (file_info.size_filename0) && (fileNameBufferSize>0)) + if (lufread(szFileName,(uInt)uSizeRead,1,s->file)!=1) + err=UNZ_ERRNO; + lSeek -= uSizeRead; + } + + + if ((err==UNZ_OK) && (extraField!=NULL)) + { + uLong uSizeRead ; + if (file_info.size_file_extrafile,lSeek,SEEK_CUR)==0) + lSeek=0; + else + err=UNZ_ERRNO; + if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0)) + if (lufread(extraField,(uInt)uSizeRead,1,s->file)!=1) + err=UNZ_ERRNO; + lSeek += file_info.size_file_extra - uSizeRead; + } + else + lSeek+=file_info.size_file_extra; + + + if ((err==UNZ_OK) && (szComment!=NULL)) + { + uLong uSizeRead ; + if (file_info.size_file_commentfile,lSeek,SEEK_CUR)==0) + {} // unused lSeek=0; + else + err=UNZ_ERRNO; + if ((file_info.size_file_comment>0) && (commentBufferSize>0)) + if (lufread(szComment,(uInt)uSizeRead,1,s->file)!=1) + err=UNZ_ERRNO; + //unused lSeek+=file_info.size_file_comment - uSizeRead; + } + else {} //unused lSeek+=file_info.size_file_comment; + + if ((err==UNZ_OK) && (pfile_info!=NULL)) + *pfile_info=file_info; + + if ((err==UNZ_OK) && (pfile_info_internal!=NULL)) + *pfile_info_internal=file_info_internal; + + return err; +} + + + +// Write info about the ZipFile in the *pglobal_info structure. +// No preparation of the structure is needed +// return UNZ_OK if there is no problem. +int unzGetCurrentFileInfo (unzFile file, unz_file_info *pfile_info, + char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, + char *szComment, uLong commentBufferSize) +{ return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL,szFileName,fileNameBufferSize, + extraField,extraFieldBufferSize, szComment,commentBufferSize); +} + + +// Set the current file of the zipfile to the first file. +// return UNZ_OK if there is no problem +int unzGoToFirstFile (unzFile file) +{ + int err; + unz_s* s; + if (file==NULL) return UNZ_PARAMERROR; + s=(unz_s*)file; + s->pos_in_central_dir=s->offset_central_dir; + s->num_file=0; + err=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, + &s->cur_file_info_internal, + NULL,0,NULL,0,NULL,0); + s->current_file_ok = (err == UNZ_OK); + return err; +} + + +// Set the current file of the zipfile to the next file. +// return UNZ_OK if there is no problem +// return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. +int unzGoToNextFile (unzFile file) +{ + unz_s* s; + int err; + + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + if (!s->current_file_ok) + return UNZ_END_OF_LIST_OF_FILE; + if (s->num_file+1==s->gi.number_entry) + return UNZ_END_OF_LIST_OF_FILE; + + s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename + + s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ; + s->num_file++; + err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, + &s->cur_file_info_internal, + NULL,0,NULL,0,NULL,0); + s->current_file_ok = (err == UNZ_OK); + return err; +} + + +// Try locate the file szFileName in the zipfile. +// For the iCaseSensitivity signification, see unzStringFileNameCompare +// return value : +// UNZ_OK if the file is found. It becomes the current file. +// UNZ_END_OF_LIST_OF_FILE if the file is not found +int unzLocateFile (unzFile file, const TCHAR *szFileName, int iCaseSensitivity) +{ + unz_s* s; + int err; + + uLong num_fileSaved; + uLong pos_in_central_dirSaved; + + if (file==NULL) + return UNZ_PARAMERROR; + + if (_tcslen(szFileName)>=UNZ_MAXFILENAMEINZIP) + return UNZ_PARAMERROR; + + char szFileNameA[MAX_PATH]; + +#ifdef _UNICODE + GetAnsiFileName(szFileName, szFileNameA, MAX_PATH-1); +#else + strcpy(szFileNameA, szFileName); +#endif + + s=(unz_s*)file; + if (!s->current_file_ok) + return UNZ_END_OF_LIST_OF_FILE; + + num_fileSaved = s->num_file; + pos_in_central_dirSaved = s->pos_in_central_dir; + + err = unzGoToFirstFile(file); + + while (err == UNZ_OK) + { + char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1]; + unzGetCurrentFileInfo(file,NULL, + szCurrentFileName,sizeof(szCurrentFileName)-1, + NULL,0,NULL,0); + if (unzStringFileNameCompare(szCurrentFileName,szFileNameA,iCaseSensitivity)==0) + return UNZ_OK; + err = unzGoToNextFile(file); + } + + s->num_file = num_fileSaved ; + s->pos_in_central_dir = pos_in_central_dirSaved ; + return err; +} + + +// Read the local header of the current zipfile +// Check the coherency of the local header and info in the end of central +// directory about this file +// store in *piSizeVar the size of extra info in local header +// (filename and size of extra field data) +int unzlocal_CheckCurrentFileCoherencyHeader (unz_s *s,uInt *piSizeVar, + uLong *poffset_local_extrafield, uInt *psize_local_extrafield) +{ + uLong uMagic,uData,uFlags; + uLong size_filename; + uLong size_extra_field; + int err=UNZ_OK; + + *piSizeVar = 0; + *poffset_local_extrafield = 0; + *psize_local_extrafield = 0; + + if (lufseek(s->file,s->cur_file_info_internal.offset_curfile + s->byte_before_the_zipfile,SEEK_SET)!=0) + return UNZ_ERRNO; + + + if (err==UNZ_OK) + if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) + err=UNZ_ERRNO; + else if (uMagic!=0x04034b50) + err=UNZ_BADZIPFILE; + + if (unzlocal_getShort(s->file,&uData) != UNZ_OK) + err=UNZ_ERRNO; +// else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion)) +// err=UNZ_BADZIPFILE; + if (unzlocal_getShort(s->file,&uFlags) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&uData) != UNZ_OK) + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method)) + err=UNZ_BADZIPFILE; + + if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) && + (s->cur_file_info.compression_method!=Z_DEFLATED)) + err=UNZ_BADZIPFILE; + + if (unzlocal_getLong(s->file,&uData) != UNZ_OK) // date/time + err=UNZ_ERRNO; + + if (unzlocal_getLong(s->file,&uData) != UNZ_OK) // crc + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && + ((uFlags & 8)==0)) + err=UNZ_BADZIPFILE; + + if (unzlocal_getLong(s->file,&uData) != UNZ_OK) // size compr + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && + ((uFlags & 8)==0)) + err=UNZ_BADZIPFILE; + + if (unzlocal_getLong(s->file,&uData) != UNZ_OK) // size uncompr + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && + ((uFlags & 8)==0)) + err=UNZ_BADZIPFILE; + + + if (unzlocal_getShort(s->file,&size_filename) != UNZ_OK) + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename)) + err=UNZ_BADZIPFILE; + + *piSizeVar += (uInt)size_filename; + + if (unzlocal_getShort(s->file,&size_extra_field) != UNZ_OK) + err=UNZ_ERRNO; + *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile + + SIZEZIPLOCALHEADER + size_filename; + *psize_local_extrafield = (uInt)size_extra_field; + + *piSizeVar += (uInt)size_extra_field; + + return err; +} + + + + + +// Open for reading data the current file in the zipfile. +// If there is no error and the file is opened, the return value is UNZ_OK. +int unzOpenCurrentFile (unzFile file) +{ + int err; + int Store; + uInt iSizeVar; + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + uLong offset_local_extrafield; // offset of the local extra field + uInt size_local_extrafield; // size of the local extra field + + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + if (!s->current_file_ok) + return UNZ_PARAMERROR; + + if (s->pfile_in_zip_read != NULL) + unzCloseCurrentFile(file); + + if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar, + &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK) + return UNZ_BADZIPFILE; + + pfile_in_zip_read_info = (file_in_zip_read_info_s*)zmalloc(sizeof(file_in_zip_read_info_s)); + if (pfile_in_zip_read_info==NULL) + return UNZ_INTERNALERROR; + + pfile_in_zip_read_info->read_buffer=(char*)zmalloc(UNZ_BUFSIZE); + pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield; + pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield; + pfile_in_zip_read_info->pos_local_extrafield=0; + + if (pfile_in_zip_read_info->read_buffer==NULL) + { + if (pfile_in_zip_read_info!=0) zfree(pfile_in_zip_read_info); //unused pfile_in_zip_read_info=0; + return UNZ_INTERNALERROR; + } + + pfile_in_zip_read_info->stream_initialised=0; + + if ((s->cur_file_info.compression_method!=0) && (s->cur_file_info.compression_method!=Z_DEFLATED)) + { // unused err=UNZ_BADZIPFILE; + } + Store = s->cur_file_info.compression_method==0; + + pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc; + pfile_in_zip_read_info->crc32=0; + pfile_in_zip_read_info->compression_method = + s->cur_file_info.compression_method; + pfile_in_zip_read_info->file=s->file; + pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile; + + pfile_in_zip_read_info->stream.total_out = 0; + + if (!Store) + { + pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; + pfile_in_zip_read_info->stream.zfree = (free_func)0; + pfile_in_zip_read_info->stream.opaque = (voidpf)0; + + err=inflateInit2(&pfile_in_zip_read_info->stream); + if (err == Z_OK) + pfile_in_zip_read_info->stream_initialised=1; + // windowBits is passed < 0 to tell that there is no zlib header. + // Note that in this case inflate *requires* an extra "dummy" byte + // after the compressed stream in order to complete decompression and + // return Z_STREAM_END. + // In unzip, i don't wait absolutely Z_STREAM_END because I known the + // size of both compressed and uncompressed data + } + pfile_in_zip_read_info->rest_read_compressed = + s->cur_file_info.compressed_size ; + pfile_in_zip_read_info->rest_read_uncompressed = + s->cur_file_info.uncompressed_size ; + + + pfile_in_zip_read_info->pos_in_zipfile = + s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + + iSizeVar; + + pfile_in_zip_read_info->stream.avail_in = (uInt)0; + + + s->pfile_in_zip_read = pfile_in_zip_read_info; + return UNZ_OK; +} + + +// Read bytes from the current file. +// buf contain buffer where data must be copied +// len the size of buf. +// return the number of byte copied if somes bytes are copied +// return 0 if the end of file was reached +// return <0 with error code if there is an error +// (UNZ_ERRNO for IO error, or zLib error for uncompress error) +int unzReadCurrentFile (unzFile file, voidp buf, unsigned len) +{ int err=UNZ_OK; + uInt iRead = 0; + + unz_s *s = (unz_s*)file; + if (s==NULL) return UNZ_PARAMERROR; + + file_in_zip_read_info_s* pfile_in_zip_read_info = s->pfile_in_zip_read; + if (pfile_in_zip_read_info==NULL) return UNZ_PARAMERROR; + if ((pfile_in_zip_read_info->read_buffer == NULL)) return UNZ_END_OF_LIST_OF_FILE; + if (len==0) return 0; + + pfile_in_zip_read_info->stream.next_out = (Byte*)buf; + pfile_in_zip_read_info->stream.avail_out = (uInt)len; + + if (len>pfile_in_zip_read_info->rest_read_uncompressed) + { pfile_in_zip_read_info->stream.avail_out = (uInt)pfile_in_zip_read_info->rest_read_uncompressed; + } + + while (pfile_in_zip_read_info->stream.avail_out>0) + { if ((pfile_in_zip_read_info->stream.avail_in==0) && (pfile_in_zip_read_info->rest_read_compressed>0)) + { uInt uReadThis = UNZ_BUFSIZE; + if (pfile_in_zip_read_info->rest_read_compressedrest_read_compressed; + if (uReadThis == 0) return UNZ_EOF; + if (lufseek(pfile_in_zip_read_info->file, pfile_in_zip_read_info->pos_in_zipfile + pfile_in_zip_read_info->byte_before_the_zipfile,SEEK_SET)!=0) return UNZ_ERRNO; + if (lufread(pfile_in_zip_read_info->read_buffer,uReadThis,1,pfile_in_zip_read_info->file)!=1) return UNZ_ERRNO; + pfile_in_zip_read_info->pos_in_zipfile += uReadThis; + pfile_in_zip_read_info->rest_read_compressed-=uReadThis; + pfile_in_zip_read_info->stream.next_in = (Byte*)pfile_in_zip_read_info->read_buffer; + pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis; + } + + if (pfile_in_zip_read_info->compression_method==0) + { uInt uDoCopy,i ; + if (pfile_in_zip_read_info->stream.avail_out < pfile_in_zip_read_info->stream.avail_in) + { uDoCopy = pfile_in_zip_read_info->stream.avail_out ; + } + else + { uDoCopy = pfile_in_zip_read_info->stream.avail_in ; + } + for (i=0;istream.next_out+i) = *(pfile_in_zip_read_info->stream.next_in+i); + } + pfile_in_zip_read_info->crc32 = ucrc32(pfile_in_zip_read_info->crc32,pfile_in_zip_read_info->stream.next_out,uDoCopy); + pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy; + pfile_in_zip_read_info->stream.avail_in -= uDoCopy; + pfile_in_zip_read_info->stream.avail_out -= uDoCopy; + pfile_in_zip_read_info->stream.next_out += uDoCopy; + pfile_in_zip_read_info->stream.next_in += uDoCopy; + pfile_in_zip_read_info->stream.total_out += uDoCopy; + iRead += uDoCopy; + } + else + { uLong uTotalOutBefore,uTotalOutAfter; + const Byte *bufBefore; + uLong uOutThis; + int flush=Z_SYNC_FLUSH; + uTotalOutBefore = pfile_in_zip_read_info->stream.total_out; + bufBefore = pfile_in_zip_read_info->stream.next_out; + err=inflate(&pfile_in_zip_read_info->stream,flush); + uTotalOutAfter = pfile_in_zip_read_info->stream.total_out; + uOutThis = uTotalOutAfter-uTotalOutBefore; + pfile_in_zip_read_info->crc32 = ucrc32(pfile_in_zip_read_info->crc32,bufBefore,(uInt)(uOutThis)); + pfile_in_zip_read_info->rest_read_uncompressed -= uOutThis; + iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); + if (err==Z_STREAM_END) return (iRead==0) ? UNZ_EOF : iRead; //+++1.3 + //if (err==Z_STREAM_END) return (iRead==len) ? UNZ_EOF : iRead; //+++1.2 + + if (err != Z_OK) break; + } + } + + if (err==Z_OK) return iRead; + + return iRead; +} + + +// Give the current position in uncompressed data +z_off_t unztell (unzFile file) +{ + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + pfile_in_zip_read_info=s->pfile_in_zip_read; + + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; + + return (z_off_t)pfile_in_zip_read_info->stream.total_out; +} + + +// return 1 if the end of file was reached, 0 elsewhere +int unzeof (unzFile file) +{ + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + pfile_in_zip_read_info=s->pfile_in_zip_read; + + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; + + if (pfile_in_zip_read_info->rest_read_uncompressed == 0) + return 1; + else + return 0; +} + + + +// Read extra field from the current file (opened by unzOpenCurrentFile) +// This is the local-header version of the extra field (sometimes, there is +// more info in the local-header version than in the central-header) +// if buf==NULL, it return the size of the local extra field that can be read +// if buf!=NULL, len is the size of the buffer, the extra header is copied in buf. +// the return value is the number of bytes copied in buf, or (if <0) the error code +int unzGetLocalExtrafield (unzFile file,voidp buf,unsigned len) +{ + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + uInt read_now; + uLong size_to_read; + + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + pfile_in_zip_read_info=s->pfile_in_zip_read; + + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; + + size_to_read = (pfile_in_zip_read_info->size_local_extrafield - + pfile_in_zip_read_info->pos_local_extrafield); + + if (buf==NULL) + return (int)size_to_read; + + if (len>size_to_read) + read_now = (uInt)size_to_read; + else + read_now = (uInt)len ; + + if (read_now==0) + return 0; + + if (lufseek(pfile_in_zip_read_info->file, pfile_in_zip_read_info->offset_local_extrafield + pfile_in_zip_read_info->pos_local_extrafield,SEEK_SET)!=0) + return UNZ_ERRNO; + + if (lufread(buf,(uInt)size_to_read,1,pfile_in_zip_read_info->file)!=1) + return UNZ_ERRNO; + + return (int)read_now; +} + +// Close the file in zip opened with unzipOpenCurrentFile +// Return UNZ_CRCERROR if all the file was read but the CRC is not good +int unzCloseCurrentFile (unzFile file) +{ + int err=UNZ_OK; + + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + pfile_in_zip_read_info=s->pfile_in_zip_read; + + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; + + + if (pfile_in_zip_read_info->rest_read_uncompressed == 0) + { + if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait) + err=UNZ_CRCERROR; + } + + + if (pfile_in_zip_read_info->read_buffer!=0) + { void *buf = pfile_in_zip_read_info->read_buffer; + zfree(buf); + pfile_in_zip_read_info->read_buffer=0; + } + pfile_in_zip_read_info->read_buffer = NULL; + if (pfile_in_zip_read_info->stream_initialised) + inflateEnd(&pfile_in_zip_read_info->stream); + + pfile_in_zip_read_info->stream_initialised = 0; + if (pfile_in_zip_read_info!=0) zfree(pfile_in_zip_read_info); // unused pfile_in_zip_read_info=0; + + s->pfile_in_zip_read=NULL; + + return err; +} + + +// Get the global comment string of the ZipFile, in the szComment buffer. +// uSizeBuf is the size of the szComment buffer. +// return the number of byte copied or an error code <0 +int unzGetGlobalComment (unzFile file, char *szComment, uLong uSizeBuf) +{ //int err=UNZ_OK; + unz_s* s; + uLong uReadThis ; + if (file==NULL) return UNZ_PARAMERROR; + s=(unz_s*)file; + uReadThis = uSizeBuf; + if (uReadThis>s->gi.size_comment) uReadThis = s->gi.size_comment; + if (lufseek(s->file,s->central_pos+22,SEEK_SET)!=0) return UNZ_ERRNO; + if (uReadThis>0) + { *szComment='\0'; + if (lufread(szComment,(uInt)uReadThis,1,s->file)!=1) return UNZ_ERRNO; + } + if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment)) *(szComment+s->gi.size_comment)='\0'; + return (int)uReadThis; +} + + + + + +int unzOpenCurrentFile (unzFile file); +int unzReadCurrentFile (unzFile file, void *buf, unsigned len); +int unzCloseCurrentFile (unzFile file); + + +FILETIME timet2filetime(time_t timer) +{ + struct tm *tm = gmtime(&timer); + SYSTEMTIME st; + st.wYear = (WORD)(tm->tm_year+1900); + st.wMonth = (WORD)(tm->tm_mon+1); + st.wDay = (WORD)(tm->tm_mday); + st.wHour = (WORD)(tm->tm_hour); + st.wMinute = (WORD)(tm->tm_min); + st.wSecond = (WORD)(tm->tm_sec); + st.wMilliseconds=0; + FILETIME ft; + SystemTimeToFileTime(&st,&ft); + return ft; +} + +/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// +class TUnzip +{ public: + TUnzip() : uf(0), currentfile(-1), czei(-1) {} + + unzFile uf; int currentfile; ZIPENTRY cze; int czei; + TCHAR rootdir[MAX_PATH]; + + ZRESULT Open(void *z,unsigned int len,DWORD flags); + ZRESULT Get(int index,ZIPENTRY *ze); + ZRESULT Find(const TCHAR *name,bool ic,int *index,ZIPENTRY *ze); + ZRESULT Unzip(int index,void *dst,unsigned int len,DWORD flags); + ZRESULT Close(); +}; + + +ZRESULT TUnzip::Open(void *z,unsigned int len,DWORD flags) +{ + if (uf!=0 || currentfile!=-1) + return ZR_NOTINITED; + GetCurrentDirectory(MAX_PATH,rootdir); + _tcscat(rootdir,_T("\\")); + if (flags==ZIP_HANDLE) + { + DWORD type = GetFileType(z); + if (type!=FILE_TYPE_DISK) + return ZR_SEEK; + } + ZRESULT e; + LUFILE *f = lufopen(z,len,flags,&e); + if (f==NULL) + return e; + uf = unzOpenInternal(f); + //return ZR_OK; + return zopenerror; //+++1.2 +} + +ZRESULT TUnzip::Get(int index,ZIPENTRY *ze) +{ if (index<-1 || index>=(int)uf->gi.number_entry) + return ZR_ARGS; + if (currentfile!=-1) + unzCloseCurrentFile(uf); + currentfile=-1; + if (index==czei && index!=-1) {memcpy(ze,&cze,sizeof(ZIPENTRY)); return ZR_OK;} + if (index==-1) + { ze->index = uf->gi.number_entry; + ze->name[0]=0; + ze->attr=0; + ze->atime.dwLowDateTime=0; ze->atime.dwHighDateTime=0; + ze->ctime.dwLowDateTime=0; ze->ctime.dwHighDateTime=0; + ze->mtime.dwLowDateTime=0; ze->mtime.dwHighDateTime=0; + ze->comp_size=0; + ze->unc_size=0; + return ZR_OK; + } + if (index<(int)uf->num_file) unzGoToFirstFile(uf); + while ((int)uf->num_filefile,offset,SEEK_SET)!=0) return ZR_READ; + char *extra = new char[extralen]; + if (lufread(extra,1,(uInt)extralen,uf->file)!=extralen) {delete[] extra; return ZR_READ;} + // + ze->index=uf->num_file; + strcpy(ze->name,fn); + // zip has an 'attribute' 32bit value. Its lower half is windows stuff + // its upper half is standard unix attr. + unsigned long a = ufi.external_fa; + bool uisdir = (a&0x40000000)!=0; + //bool uwriteable= (a&0x08000000)!=0; + bool uwriteable= (a&0x00800000)!=0; // ***hd*** + //bool ureadable= (a&0x01000000)!=0; + //bool uexecutable=(a&0x00400000)!=0; + bool wreadonly= (a&0x00000001)!=0; + bool whidden= (a&0x00000002)!=0; + bool wsystem= (a&0x00000004)!=0; + bool wisdir= (a&0x00000010)!=0; + bool warchive= (a&0x00000020)!=0; + ze->attr=FILE_ATTRIBUTE_NORMAL; + if (uisdir || wisdir) ze->attr |= FILE_ATTRIBUTE_DIRECTORY; + if (warchive) ze->attr|=FILE_ATTRIBUTE_ARCHIVE; + if (whidden) ze->attr|=FILE_ATTRIBUTE_HIDDEN; + if (!uwriteable||wreadonly) ze->attr|=FILE_ATTRIBUTE_READONLY; + if (wsystem) ze->attr|=FILE_ATTRIBUTE_SYSTEM; + ze->comp_size = ufi.compressed_size; + ze->unc_size = ufi.uncompressed_size; + // + WORD dostime = (WORD)(ufi.dosDate&0xFFFF); + WORD dosdate = (WORD)((ufi.dosDate>>16)&0xFFFF); + FILETIME ft; + DosDateTimeToFileTime(dosdate,dostime,&ft); + ze->atime=ft; ze->ctime=ft; ze->mtime=ft; + // the zip will always have at least that dostime. But if it also has + // an extra header, then we'll instead get the info from that. + unsigned int epos=0; + while (epos+4mtime = timet2filetime(mtime); + } + if (hasatime) + { time_t atime = *(time_t*)(extra+epos); epos+=4; + ze->atime = timet2filetime(atime); + } + if (hasctime) + { time_t ctime = *(time_t*)(extra+epos); + ze->ctime = timet2filetime(ctime); + } + break; + } + // + if (extra!=0) delete[] extra; + memcpy(&cze,ze,sizeof(ZIPENTRY)); czei=index; + return ZR_OK; +} + +ZRESULT TUnzip::Find(const TCHAR *name, bool ic, int *index, ZIPENTRY *ze) +{ + int res = unzLocateFile(uf,name,ic?CASE_INSENSITIVE:CASE_SENSITIVE); + if (res!=UNZ_OK) + { + if (index!=0) + *index=-1; + if (ze!=NULL) + { + ZeroMemory(ze,sizeof(ZIPENTRY)); ze->index=-1; + } + return ZR_NOTFOUND; + } + if (currentfile!=-1) + unzCloseCurrentFile(uf); currentfile=-1; + int i = (int)uf->num_file; + if (index!=NULL) + *index=i; + if (ze!=NULL) + { + ZRESULT zres = Get(i,ze); + if (zres!=ZR_OK) + return zres; + } + return ZR_OK; +} + +void EnsureDirectory(const TCHAR *rootdir, const TCHAR *dir) +{ + if (dir==NULL || dir[0] == _T('\0')) + return; + const TCHAR *lastslash = dir, *c = lastslash; + while (*c != _T('\0')) + { + if (*c==_T('/') || *c==_T('\\')) + lastslash=c; + c++; + } + const TCHAR *name=lastslash; + if (lastslash!=dir) + { + TCHAR tmp[MAX_PATH]; + _tcsncpy(tmp, dir, lastslash-dir); + tmp[lastslash-dir] = _T('\0'); + EnsureDirectory(rootdir,tmp); + name++; + } + TCHAR cd[MAX_PATH]; + _tcscpy(cd,rootdir); + //_tcscat(cd,name); + _tcscat(cd,dir); //+++1.2 + CreateDirectory(cd,NULL); +} + +ZRESULT TUnzip::Unzip(int index,void *dst,unsigned int len,DWORD flags) +{ + if (flags!=ZIP_MEMORY && flags!=ZIP_FILENAME && flags!=ZIP_HANDLE) + return ZR_ARGS; + if (flags==ZIP_MEMORY) + { + if (index!=currentfile) + { + if (currentfile!=-1) + unzCloseCurrentFile(uf); + currentfile=-1; + if (index>=(int)uf->gi.number_entry) + return ZR_ARGS; + if (index<(int)uf->num_file) + unzGoToFirstFile(uf); + while ((int)uf->num_file0) + return ZR_MORE; + unzCloseCurrentFile(uf); + currentfile=-1; + if (res==0) + return ZR_OK; + else + return ZR_FLATE; + } + + // otherwise we're writing to a handle or a file + if (currentfile!=-1) + unzCloseCurrentFile(uf); + currentfile=-1; + if (index >= (int)uf->gi.number_entry) + return ZR_ARGS; + if (index < (int)uf->num_file) + unzGoToFirstFile(uf); + while ((int)uf->num_filelen) n=len-1; + strncpy(buf,msg,n); buf[n]=0; + return mlen; +} + + +typedef struct +{ DWORD flag; + TUnzip *unz; +} TUnzipHandleData; + +HZIP OpenZipU(void *z,unsigned int len,DWORD flags) +{ + TUnzip *unz = new TUnzip(); + lasterrorU = unz->Open(z,len,flags); + if (lasterrorU!=ZR_OK) + { + delete unz; + return 0; + } + TUnzipHandleData *han = new TUnzipHandleData; + han->flag=1; + han->unz=unz; + return (HZIP)han; +} + +ZRESULT GetZipItemA(HZIP hz, int index, ZIPENTRY *ze) +{ + if (hz==0) + { + lasterrorU=ZR_ARGS; + return ZR_ARGS; + } + TUnzipHandleData *han = (TUnzipHandleData*)hz; + if (han->flag!=1) + { + lasterrorU=ZR_ZMODE; + return ZR_ZMODE; + } + TUnzip *unz = han->unz; + lasterrorU = unz->Get(index,ze); + return lasterrorU; +} + +ZRESULT GetZipItemW(HZIP hz, int index, ZIPENTRYW *zew) +{ + if (hz==0) + { + lasterrorU=ZR_ARGS; + return ZR_ARGS; + } + TUnzipHandleData *han = (TUnzipHandleData*)hz; + if (han->flag!=1) + { + lasterrorU=ZR_ZMODE; + return ZR_ZMODE; + } + TUnzip *unz = han->unz; + ZIPENTRY ze; + lasterrorU = unz->Get(index,&ze); + if (lasterrorU == ZR_OK) + { + zew->index = ze.index; + zew->attr = ze.attr; + zew->atime = ze.atime; + zew->ctime = ze.ctime; + zew->mtime = ze.mtime; + zew->comp_size = ze.comp_size; + zew->unc_size = ze.unc_size; +#ifdef _UNICODE + GetUnicodeFileName(ze.name, zew->name, MAX_PATH-1); +#else + strcpy(zew->name, ze.name); +#endif + } + return lasterrorU; +} + +ZRESULT FindZipItemA(HZIP hz, const TCHAR *name, bool ic, int *index, ZIPENTRY *ze) +{ + if (hz==0) + { + lasterrorU=ZR_ARGS; + return ZR_ARGS; + } + TUnzipHandleData *han = (TUnzipHandleData*)hz; + if (han->flag!=1) + { + lasterrorU=ZR_ZMODE; + return ZR_ZMODE; + } + TUnzip *unz = han->unz; + lasterrorU = unz->Find(name,ic,index,ze); + return lasterrorU; +} + +ZRESULT FindZipItemW(HZIP hz, const TCHAR *name, bool ic, int *index, ZIPENTRYW *zew) +{ + if (hz==0) + { + lasterrorU=ZR_ARGS; + return ZR_ARGS; + } + TUnzipHandleData *han = (TUnzipHandleData*)hz; + if (han->flag!=1) + { + lasterrorU=ZR_ZMODE; + return ZR_ZMODE; + } + TUnzip *unz = han->unz; + ZIPENTRY ze; + lasterrorU = unz->Find(name,ic,index,&ze); + if (lasterrorU == ZR_OK) + { + zew->index = ze.index; + zew->attr = ze.attr; + zew->atime = ze.atime; + zew->ctime = ze.ctime; + zew->mtime = ze.mtime; + zew->comp_size = ze.comp_size; + zew->unc_size = ze.unc_size; +#ifdef _UNICODE + GetUnicodeFileName(ze.name, zew->name, MAX_PATH-1); +#else + strcpy(zew->name, ze.name); +#endif + } + + return lasterrorU; +} + +ZRESULT UnzipItem(HZIP hz, int index, void *dst, unsigned int len, DWORD flags) +{ + if (hz==0) + { + lasterrorU=ZR_ARGS; + return ZR_ARGS; + } + TUnzipHandleData *han = (TUnzipHandleData*)hz; + if (han->flag!=1) + { + lasterrorU=ZR_ZMODE; + return ZR_ZMODE; + } + TUnzip *unz = han->unz; + lasterrorU = unz->Unzip(index,dst,len,flags); + return lasterrorU; +} + +ZRESULT CloseZipU(HZIP hz) +{ if (hz==0) {lasterrorU=ZR_ARGS;return ZR_ARGS;} + TUnzipHandleData *han = (TUnzipHandleData*)hz; + if (han->flag!=1) {lasterrorU=ZR_ZMODE;return ZR_ZMODE;} + TUnzip *unz = han->unz; + lasterrorU = unz->Close(); + delete unz; + delete han; + return lasterrorU; +} + +bool IsZipHandleU(HZIP hz) +{ if (hz==0) return true; + TUnzipHandleData *han = (TUnzipHandleData*)hz; + return (han->flag==1); +} + + diff --git a/setup/installer/windows/XUnzip.h b/setup/installer/windows/XUnzip.h new file mode 100644 index 0000000000..aa39ca142e --- /dev/null +++ b/setup/installer/windows/XUnzip.h @@ -0,0 +1,382 @@ +// XUnzip.h Version 1.3 +// +// Authors: Mark Adler et al. (see below) +// +// Modified by: Lucian Wischik +// lu@wischik.com +// +// Version 1.0 - Turned C files into just a single CPP file +// - Made them compile cleanly as C++ files +// - Gave them simpler APIs +// - Added the ability to zip/unzip directly in memory without +// any intermediate files +// +// Modified by: Hans Dietrich +// hdietrich@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// +// +// Lucian Wischik's comments: +// -------------------------- +// THIS FILE is almost entirely based upon code by info-zip. +// It has been modified by Lucian Wischik. +// The original code may be found at http://www.info-zip.org +// The original copyright text follows. +// +/////////////////////////////////////////////////////////////////////////////// +// +// Original authors' comments: +// --------------------------- +// This is version 2002-Feb-16 of the Info-ZIP copyright and license. The +// definitive version of this document should be available at +// ftp://ftp.info-zip.org/pub/infozip/license.html indefinitely. +// +// Copyright (c) 1990-2002 Info-ZIP. All rights reserved. +// +// For the purposes of this copyright and license, "Info-ZIP" is defined as +// the following set of individuals: +// +// Mark Adler, John Bush, Karl Davis, Harald Denker, Jean-Michel Dubois, +// Jean-loup Gailly, Hunter Goatley, Ian Gorman, Chris Herborth, Dirk Haase, +// Greg Hartwig, Robert Heath, Jonathan Hudson, Paul Kienitz, +// David Kirschbaum, Johnny Lee, Onno van der Linden, Igor Mandrichenko, +// Steve P. Miller, Sergio Monesi, Keith Owens, George Petrov, Greg Roelofs, +// Kai Uwe Rommel, Steve Salisbury, Dave Smith, Christian Spieler, +// Antoine Verheijen, Paul von Behren, Rich Wales, Mike White +// +// This software is provided "as is", without warranty of any kind, express +// or implied. In no event shall Info-ZIP or its contributors be held liable +// for any direct, indirect, incidental, special or consequential damages +// arising out of the use of or inability to use this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. Redistributions of source code must retain the above copyright notice, +// definition, disclaimer, and this list of conditions. +// +// 2. Redistributions in binary form (compiled executables) must reproduce +// the above copyright notice, definition, disclaimer, and this list of +// conditions in documentation and/or other materials provided with the +// distribution. The sole exception to this condition is redistribution +// of a standard UnZipSFX binary as part of a self-extracting archive; +// that is permitted without inclusion of this license, as long as the +// normal UnZipSFX banner has not been removed from the binary or disabled. +// +// 3. Altered versions--including, but not limited to, ports to new +// operating systems, existing ports with new graphical interfaces, and +// dynamic, shared, or static library versions--must be plainly marked +// as such and must not be misrepresented as being the original source. +// Such altered versions also must not be misrepresented as being +// Info-ZIP releases--including, but not limited to, labeling of the +// altered versions with the names "Info-ZIP" (or any variation thereof, +// including, but not limited to, different capitalizations), +// "Pocket UnZip", "WiZ" or "MacZip" without the explicit permission of +// Info-ZIP. Such altered versions are further prohibited from +// misrepresentative use of the Zip-Bugs or Info-ZIP e-mail addresses or +// of the Info-ZIP URL(s). +// +// 4. Info-ZIP retains the right to use the names "Info-ZIP", "Zip", "UnZip", +// "UnZipSFX", "WiZ", "Pocket UnZip", "Pocket Zip", and "MacZip" for its +// own source and binary releases. +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef XUNZIP_H +#define XUNZIP_H + + +#ifndef XZIP_H +DECLARE_HANDLE(HZIP); // An HZIP identifies a zip file that has been opened +#endif + +typedef DWORD ZRESULT; +// return codes from any of the zip functions. Listed later. + +#define ZIP_HANDLE 1 +#define ZIP_FILENAME 2 +#define ZIP_MEMORY 3 + +typedef struct +{ int index; // index of this file within the zip + char name[MAX_PATH]; // filename within the zip + DWORD attr; // attributes, as in GetFileAttributes. + FILETIME atime,ctime,mtime;// access, create, modify filetimes + long comp_size; // sizes of item, compressed and uncompressed. These + long unc_size; // may be -1 if not yet known (e.g. being streamed in) +} ZIPENTRY; + +typedef struct +{ int index; // index of this file within the zip + TCHAR name[MAX_PATH]; // filename within the zip + DWORD attr; // attributes, as in GetFileAttributes. + FILETIME atime,ctime,mtime;// access, create, modify filetimes + long comp_size; // sizes of item, compressed and uncompressed. These + long unc_size; // may be -1 if not yet known (e.g. being streamed in) +} ZIPENTRYW; + + +/////////////////////////////////////////////////////////////////////////////// +// +// OpenZip() +// +// Purpose: Open an existing zip archive file +// +// Parameters: z - archive file name if flags is ZIP_FILENAME; for other +// uses see below +// len - for memory (ZIP_MEMORY) should be the buffer size; +// for other uses, should be 0 +// flags - indicates usage, see below; for files, this will be +// ZIP_FILENAME +// +// Returns: HZIP - non-zero if zip archive opened ok, otherwise 0 +// +HZIP OpenZip(void *z, unsigned int len, DWORD flags); +// OpenZip - opens a zip file and returns a handle with which you can +// subsequently examine its contents. You can open a zip file from: +// from a pipe: OpenZip(hpipe_read,0, ZIP_HANDLE); +// from a file (by handle): OpenZip(hfile,0, ZIP_HANDLE); +// from a file (by name): OpenZip("c:\\test.zip",0, ZIP_FILENAME); +// from a memory block: OpenZip(bufstart, buflen, ZIP_MEMORY); +// If the file is opened through a pipe, then items may only be +// accessed in increasing order, and an item may only be unzipped once, +// although GetZipItem can be called immediately before and after unzipping +// it. If it's opened i n any other way, then full random access is possible. +// Note: pipe input is not yet implemented. + + +/////////////////////////////////////////////////////////////////////////////// +// +// GetZipItem() +// +// Purpose: Get information about an item in an open zip archive +// +// Parameters: hz - handle of open zip archive +// index - index number (0 based) of item in zip +// ze - pointer to a ZIPENTRY (if ANSI) or ZIPENTRYW struct +// (if Unicode) +// +// Returns: ZRESULT - ZR_OK if success, otherwise some other value +// + +#ifdef _UNICODE +#define GetZipItem GetZipItemW +#else +#define GetZipItem GetZipItemA +#endif + +ZRESULT GetZipItemA(HZIP hz, int index, ZIPENTRY *ze); +ZRESULT GetZipItemW(HZIP hz, int index, ZIPENTRYW *ze); +// GetZipItem - call this to get information about an item in the zip. +// If index is -1 and the file wasn't opened through a pipe, +// then it returns information about the whole zipfile +// (and in particular ze.index returns the number of index items). +// Note: the item might be a directory (ze.attr & FILE_ATTRIBUTE_DIRECTORY) +// See below for notes on what happens when you unzip such an item. +// Note: if you are opening the zip through a pipe, then random access +// is not possible and GetZipItem(-1) fails and you can't discover the number +// of items except by calling GetZipItem on each one of them in turn, +// starting at 0, until eventually the call fails. Also, in the event that +// you are opening through a pipe and the zip was itself created into a pipe, +// then then comp_size and sometimes unc_size as well may not be known until +// after the item has been unzipped. + + +/////////////////////////////////////////////////////////////////////////////// +// +// FindZipItem() +// +// Purpose: Find item by name and return information about it +// +// Parameters: hz - handle of open zip archive +// name - name of file to look for inside zip archive +// ic - TRUE = case insensitive +// index - pointer to index number returned, or -1 +// ze - pointer to a ZIPENTRY (if ANSI) or ZIPENTRYW struct +// (if Unicode) +// +// Returns: ZRESULT - ZR_OK if success, otherwise some other value +// + +#ifdef _UNICODE +#define FindZipItem FindZipItemW +#else +#define FindZipItem FindZipItemA +#endif + +ZRESULT FindZipItemA(HZIP hz, const TCHAR *name, bool ic, int *index, ZIPENTRY *ze); +ZRESULT FindZipItemW(HZIP hz, const TCHAR *name, bool ic, int *index, ZIPENTRYW *ze); +// FindZipItem - finds an item by name. ic means 'insensitive to case'. +// It returns the index of the item, and returns information about it. +// If nothing was found, then index is set to -1 and the function returns +// an error code. + + +/////////////////////////////////////////////////////////////////////////////// +// +// UnzipItem() +// +// Purpose: Find item by index and unzip it +// +// Parameters: hz - handle of open zip archive +// index - index number of file to unzip +// dst - target file name of unzipped file +// len - for memory (ZIP_MEMORY. length of buffer; +// otherwise 0 +// flags - indicates usage, see below; for files, this will be +// ZIP_FILENAME +// +// Returns: ZRESULT - ZR_OK if success, otherwise some other value +// + +ZRESULT UnzipItem(HZIP hz, int index, void *dst, unsigned int len, DWORD flags); +// UnzipItem - given an index to an item, unzips it. You can unzip to: +// to a pipe: UnzipItem(hz,i, hpipe_write,0,ZIP_HANDLE); +// to a file (by handle): UnzipItem(hz,i, hfile,0,ZIP_HANDLE); +// to a file (by name): UnzipItem(hz,i, ze.name,0,ZIP_FILENAME); +// to a memory block: UnzipItem(hz,i, buf,buflen,ZIP_MEMORY); +// In the final case, if the buffer isn't large enough to hold it all, +// then the return code indicates that more is yet to come. If it was +// large enough, and you want to know precisely how big, GetZipItem. +// Note: zip files are normally stored with relative pathnames. If you +// unzip with ZIP_FILENAME a relative pathname then the item gets created +// relative to the current directory - it first ensures that all necessary +// subdirectories have been created. Also, the item may itself be a directory. +// If you unzip a directory with ZIP_FILENAME, then the directory gets created. +// If you unzip it to a handle or a memory block, then nothing gets created +// and it emits 0 bytes. + + +/////////////////////////////////////////////////////////////////////////////// +// +// CloseZip() +// +// Purpose: Close an open zip archive +// +// Parameters: hz - handle to an open zip archive +// +// Returns: ZRESULT - ZR_OK if success, otherwise some other value +// +ZRESULT CloseZip(HZIP hz); +// CloseZip - the zip handle must be closed with this function. + +unsigned int FormatZipMessage(ZRESULT code, char *buf,unsigned int len); +// FormatZipMessage - given an error code, formats it as a string. +// It returns the length of the error message. If buf/len points +// to a real buffer, then it also writes as much as possible into there. + + +// These are the result codes: +#define ZR_OK 0x00000000 // nb. the pseudo-code zr-recent is never returned, +#define ZR_RECENT 0x00000001 // but can be passed to FormatZipMessage. +// The following come from general system stuff (e.g. files not openable) +#define ZR_GENMASK 0x0000FF00 +#define ZR_NODUPH 0x00000100 // couldn't duplicate the handle +#define ZR_NOFILE 0x00000200 // couldn't create/open the file +#define ZR_NOALLOC 0x00000300 // failed to allocate some resource +#define ZR_WRITE 0x00000400 // a general error writing to the file +#define ZR_NOTFOUND 0x00000500 // couldn't find that file in the zip +#define ZR_MORE 0x00000600 // there's still more data to be unzipped +#define ZR_CORRUPT 0x00000700 // the zipfile is corrupt or not a zipfile +#define ZR_READ 0x00000800 // a general error reading the file +// The following come from mistakes on the part of the caller +#define ZR_CALLERMASK 0x00FF0000 +#define ZR_ARGS 0x00010000 // general mistake with the arguments +#define ZR_NOTMMAP 0x00020000 // tried to ZipGetMemory, but that only works on mmap zipfiles, which yours wasn't +#define ZR_MEMSIZE 0x00030000 // the memory size is too small +#define ZR_FAILED 0x00040000 // the thing was already failed when you called this function +#define ZR_ENDED 0x00050000 // the zip creation has already been closed +#define ZR_MISSIZE 0x00060000 // the indicated input file size turned out mistaken +#define ZR_PARTIALUNZ 0x00070000 // the file had already been partially unzipped +#define ZR_ZMODE 0x00080000 // tried to mix creating/opening a zip +// The following come from bugs within the zip library itself +#define ZR_BUGMASK 0xFF000000 +#define ZR_NOTINITED 0x01000000 // initialisation didn't work +#define ZR_SEEK 0x02000000 // trying to seek in an unseekable file +#define ZR_NOCHANGE 0x04000000 // changed its mind on storage, but not allowed +#define ZR_FLATE 0x05000000 // an internal error in the de/inflation code + + + + + +// e.g. +// +// SetCurrentDirectory("c:\\docs\\stuff"); +// HZIP hz = OpenZip("c:\\stuff.zip",0,ZIP_FILENAME); +// ZIPENTRY ze; GetZipItem(hz,-1,&ze); int numitems=ze.index; +// for (int i=0; i +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include "XUnzip.h" + +#define BUFSIZE 4096 + +// Error handling {{{ + +static void show_error(LPCWSTR msg) { + MessageBeep(MB_ICONERROR); + MessageBox(NULL, msg, L"Error", MB_OK|MB_ICONERROR); +} + +static void show_detailed_error(LPCWSTR preamble, LPCWSTR msg, int code) { + LPWSTR buf; + buf = (LPWSTR)LocalAlloc(LMEM_ZEROINIT, sizeof(WCHAR)* + (wcslen(msg) + wcslen(preamble) + 80)); + + _snwprintf_s(buf, + LocalSize(buf) / sizeof(WCHAR), _TRUNCATE, + L"%s\r\n %s (Error Code: %d)\r\n", + preamble, msg, code); + + show_error(buf); + LocalFree(buf); +} + +static void show_zip_error(LPCWSTR preamble, LPCWSTR msg, ZRESULT code) { + LPWSTR buf; + buf = (LPWSTR)LocalAlloc(LMEM_ZEROINIT, sizeof(WCHAR)* + (wcslen(preamble) + wcslen(msg) + 80)); + + _snwprintf_s(buf, + LocalSize(buf) / sizeof(WCHAR), _TRUNCATE, + L"%s\r\n %s %s (Error Code: %X)\r\n", + preamble, msg, code); + + show_error(buf); + LocalFree(buf); +} + +static void show_last_error_crt(LPCWSTR preamble) { + WCHAR buf[BUFSIZE]; + int err = 0; + + _get_errno(&err); + _wcserror_s(buf, BUFSIZE, err); + show_detailed_error(preamble, buf, err); +} + +static void show_last_error(LPCWSTR preamble) { + WCHAR *msg = NULL; + DWORD dw = GetLastError(); + + FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + dw, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPWSTR)&msg, + 0, NULL ); + + show_detailed_error(preamble, msg, (int)dw); +} + +// }}} + +// Load, decompress and extract data {{{ + +static BOOL load_data(LPVOID *data, DWORD *sz) { + HRSRC rsrc; + HGLOBAL h; + + rsrc = FindResourceW(NULL, L"extra", L"extra"); + if (rsrc == NULL) { show_last_error(L"Failed to find portable data in exe"); return false; } + + h = LoadResource(NULL, rsrc); + if (h == NULL) { show_last_error(L"Failed to load portable data from exe"); return false; } + + *data = LockResource(h); + if (*data == NULL) { show_last_error(L"Failed to lock portable data in exe"); return false; } + + *sz = SizeofResource(NULL, rsrc); + if (sz == 0) { show_last_error(L"Failed to get size of portable data in exe"); return false; } + + return true; +} + +static BOOL unzip(HZIP zipf, int nitems, IProgressDialog *pd) { + int i = 0; + ZRESULT res; + ZIPENTRYW ze; + + for (i = 0; i < nitems; i++) { + res = GetZipItem(zipf, i, &ze); + if (res != ZR_OK) { show_zip_error(L"Failed to get zip item", L"", res); return false;} + + res = UnzipItem(zipf, i, ze.name, 0, ZIP_FILENAME); + if (res != ZR_OK) { show_zip_error(L"Failed to extract zip item:", ze.name, res); return false;} + + pd->SetLine(2, ze.name, true, NULL); + pd->SetProgress(i, nitems); + } + + CloseZip(zipf); + + return true; +} + +static HANDLE temp_file(LPWSTR name) { + UINT res; + HANDLE h; + + res = GetTempFileNameW(L".", L"portable_data", 0, name); + + if (res == 0) { show_last_error(L"Failed to create temporary file to decompress portable data"); return INVALID_HANDLE_VALUE; } + + h = CreateFile(name, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if (h == INVALID_HANDLE_VALUE) { show_last_error(L"Failed to open temp file t decomress portable data"); } + return h; + +} + +struct DataStream +{ + const unsigned char *in_data; + size_t in_len; + + HANDLE out; + IProgressDialog *pd; +}; + +static int +input_callback(void *ctx, void *buf, size_t * size) +{ + size_t rd = 0; + struct DataStream * ds = (struct DataStream *) ctx; + + rd = (ds->in_len < *size) ? ds->in_len : *size; + + if (rd > 0) { + memcpy(buf, (void*) ds->in_data, rd); + ds->in_data += rd; + ds->in_len -= rd; + } + + *size = rd; + + return 0; +} + +static size_t +output_callback(void *ctx, const void *buf, size_t size) +{ + struct DataStream * ds = (struct DataStream *) ctx; + DWORD written = 0; + + if (size > 0) { + if (!WriteFile(ds->out, buf, size, &written, NULL)) { + show_last_error(L"Failed to write uncompressed data to temp file"); + return 0; + } + written = SetFilePointer(ds->out, 0, NULL, FILE_CURRENT); + ds->pd->SetProgress(written, UNCOMPRESSED_SIZE); + } + + return size; +} + +static BOOL decompress(LPVOID src, DWORD src_sz, HANDLE out, IProgressDialog *pd) { + elzma_decompress_handle h; + struct DataStream ds; + int rc; + + h = elzma_decompress_alloc(); + + if (h == NULL) { show_error(L"Out of memory"); return false; } + + ds.in_data = (unsigned char*)src; + ds.in_len = src_sz; + ds.out = out; + ds.pd = pd; + + rc = elzma_decompress_run(h, input_callback, (void *) &ds, output_callback, + (void *) &ds, ELZMA_lzip); + + if (rc != ELZMA_E_OK) { + elzma_decompress_free(&h); + show_zip_error(L"Failed to decompress portable data", L"", rc); + return false; + } + + elzma_decompress_free(&h); + + return true; +} + +static BOOL extract(LPVOID cdata, DWORD csz) { + HANDLE h; + WCHAR tempnam[MAX_PATH+1] = {0}; + BOOL ret = true; + HZIP zipf; + ZIPENTRYW ze; + ZRESULT res; + int nitems; + HRESULT hr; + IProgressDialog *pd = NULL; + + hr = CoCreateInstance(CLSID_ProgressDialog, NULL, + CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pd)); + + if (FAILED(hr)) { show_error(L"Failed to create progress dialog"); return false; } + pd->SetTitle(L"Extracting Calibre Portable"); + pd->SetLine(1, L"Decompressing data...", true, NULL); + + h = temp_file(tempnam); + if (h == INVALID_HANDLE_VALUE) return false; + + pd->StartProgressDialog(NULL, NULL, PROGDLG_NORMAL | PROGDLG_AUTOTIME | PROGDLG_NOCANCEL, NULL); + if (!decompress(cdata, csz, h, pd)) { ret = false; goto end; } + SetFilePointer(h, 0, NULL, FILE_BEGIN); + zipf = OpenZip(h, 0, ZIP_HANDLE); + if (zipf == 0) { show_last_error(L"Failed to open zipped portable data"); ret = false; goto end; } + + res = GetZipItem(zipf, -1, &ze); + if (res != ZR_OK) { show_zip_error(L"Failed to get count of items in portable data", L"", res); ret = false; goto end;} + nitems = ze.index; + + pd->SetLine(1, L"Copying files...", true, NULL); + if (!unzip(zipf, nitems, pd)) { ret = false; goto end; } +end: + pd->StopProgressDialog(); + pd->Release(); + CloseHandle(h); + DeleteFile(tempnam); + return ret; +} + +// }}} + +// Find calibre portable directory and install/upgrade into it {{{ + +static BOOL directory_exists( LPCWSTR path ) +{ + if( _waccess_s( path, 0 ) == 0 ) + { + struct _stat status; + _wstat( path, &status ); + return (status.st_mode & S_IFDIR) != 0; + } + + return FALSE; +} + +static BOOL file_exists( LPCWSTR path ) +{ + if( _waccess_s( path, 0 ) == 0 ) + { + struct _stat status; + _wstat( path, &status ); + return (status.st_mode & S_IFREG) != 0; + } + + return FALSE; +} + +static LPWSTR get_directory_from_user() { + WCHAR name[MAX_PATH+1] = {0}; + LPWSTR path = NULL; + PIDLIST_ABSOLUTE ret; + + path = (LPWSTR)calloc(2*MAX_PATH, sizeof(WCHAR)); + if (path == NULL) { show_error(L"Out of memory"); return NULL; } + + int image = 0; + BROWSEINFO bi = { NULL, NULL, name, + L"Select the folder where you want to install or update Calibre Portable", + BIF_RETURNONLYFSDIRS | BIF_DONTGOBELOWDOMAIN | BIF_USENEWUI, + NULL, NULL, image }; + + ret = SHBrowseForFolder(&bi); + if (ret == NULL) { + return NULL; + } + + if (!SHGetPathFromIDList(ret, path)) { + show_detailed_error(L"The selected folder is not valid: ", name, 0); + return NULL; + } + + return path; + +} + +static bool is_dots(LPCWSTR name) { + return wcscmp(name, L".") == 0 || wcscmp(name, L"..") == 0; +} + +static bool rmtree(LPCWSTR path) { + SHFILEOPSTRUCTW op; + WCHAR buf[4*MAX_PATH + 2] = {0}; + + if (GetFullPathName(path, 4*MAX_PATH, buf, NULL) == 0) return false; + + op.hwnd = NULL; + op.wFunc = FO_DELETE; + op.pFrom = buf; + op.pTo = NULL; + op.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT | FOF_NOCONFIRMMKDIR; + op.fAnyOperationsAborted = false; + op.hNameMappings = NULL; + op.lpszProgressTitle = NULL; + + return SHFileOperationW(&op) == 0; +} + +static BOOL find_portable_dir(LPCWSTR base, LPWSTR *result, BOOL *existing) { + WCHAR buf[4*MAX_PATH] = {0}; + + _snwprintf_s(buf, 4*MAX_PATH, _TRUNCATE, L"%s\\calibre-portable.exe", base); + *existing = true; + + if (file_exists(buf)) { + *result = _wcsdup(base); + if (*result == NULL) { show_error(L"Out of memory"); return false; } + return true; + } + + WIN32_FIND_DATA fdFile; + HANDLE hFind = NULL; + _snwprintf_s(buf, 4*MAX_PATH, _TRUNCATE, L"%s\\*", base); + + if((hFind = FindFirstFileEx(buf, FindExInfoStandard, &fdFile, FindExSearchLimitToDirectories, NULL, 0)) != INVALID_HANDLE_VALUE) { + do { + if(is_dots(fdFile.cFileName)) continue; + + if(fdFile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + _snwprintf_s(buf, 4*MAX_PATH, _TRUNCATE, L"%s\\%s\\calibre-portable.exe", base, fdFile.cFileName); + if (file_exists(buf)) { + *result = _wcsdup(buf); + if (*result == NULL) { show_error(L"Out of memory"); return false; } + PathRemoveFileSpec(*result); + FindClose(hFind); + return true; + } + } + } while(FindNextFile(hFind, &fdFile)); + FindClose(hFind); + } + + *existing = false; + _snwprintf_s(buf, 4*MAX_PATH, _TRUNCATE, L"%s\\Calibre Portable", base); + if (!CreateDirectory(buf, NULL) && GetLastError() != ERROR_ALREADY_EXISTS) { + show_last_error(L"Failed to create Calibre Portable folder"); + return false; + } + *result = _wcsdup(buf); + if (*result == NULL) { show_error(L"Out of memory"); return false; } + + return true; +} + +static LPWSTR make_unpack_dir() { + WCHAR buf[4*MAX_PATH] = {0}; + LPWSTR ans = NULL; + + if (directory_exists(L"_unpack_calibre_portable")) + rmtree(L"_unpack_calibre_portable"); + + if (!CreateDirectory(L"_unpack_calibre_portable", NULL) && GetLastError() != ERROR_ALREADY_EXISTS) { + show_last_error(L"Failed to create temporary folder to unpack into"); + return ans; + } + + if (!GetFullPathName(L"_unpack_calibre_portable", 4*MAX_PATH, buf, NULL)) { + show_last_error(L"Failed to resolve path"); + return NULL; + } + + ans = _wcsdup(buf); + if (ans == NULL) show_error(L"Out of memory"); + return ans; + +} + +static BOOL move_program() { + if (MoveFileEx(L"Calibre Portable\\calibre-portable.exe", + L"..\\calibre-portable.exe", MOVEFILE_REPLACE_EXISTING) == 0) { + show_last_error(L"Failed to move calibre-portable.exe, make sure calibre is not running"); + return false; + } + + if (directory_exists(L"..\\Calibre")) { + if (!rmtree(L"..\\Calibre")) { + show_error(L"Failed to delete the Calibre program folder. Make sure calibre is not running."); + return false; + } + } + + if (MoveFileEx(L"Calibre Portable\\Calibre", L"..\\Calibre", 0) == 0) { + show_last_error(L"Failed to move calibre program folder"); + return false; + } + + if (!directory_exists(L"..\\Calibre Library")) { + MoveFileEx(L"Calibre Portable\\Calibre Library", L"..\\Calibre Library", 0); + } + + if (!directory_exists(L"..\\Calibre Settings")) { + MoveFileEx(L"Calibre Portable\\Calibre Settings", L"..\\Calibre Settings", 0); + } + + return true; +} +// }}} + +static void launch_calibre() { + STARTUPINFO si; + PROCESS_INFORMATION pi; + + ZeroMemory( &si, sizeof(si) ); + si.cb = sizeof(si); + ZeroMemory( &pi, sizeof(pi) ); + + + if (CreateProcess(_wcsdup(L"calibre-portable.exe"), NULL, + NULL, NULL, FALSE, CREATE_UNICODE_ENVIRONMENT | CREATE_NEW_PROCESS_GROUP, + NULL, NULL, &si, &pi) + == 0) { + show_last_error(L"Failed to launch calibre portable"); + } + + // Close process and thread handles. + CloseHandle( pi.hProcess ); + CloseHandle( pi.hThread ); + +} + +int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow) +{ + + LPVOID cdata = NULL; + DWORD csz = 0; + int ret = 0, argc; + HRESULT hr; + LPWSTR tgt = NULL, dest = NULL, *argv, unpack_dir = NULL; + BOOL existing = false, launch = false; + WCHAR buf[4*MAX_PATH] = {0}, mb_msg[4*MAX_PATH] = {0}, fdest[4*MAX_PATH] = {0}; + + if (!load_data(&cdata, &csz)) return 0; + + hr = CoInitialize(NULL); + if (FAILED(hr)) { show_error(L"Failed to initialize COM"); return 0; } + + // Get the target directory for installation + argv = CommandLineToArgvW(GetCommandLine(), &argc); + if (argv == NULL) { show_last_error(L"Failed to get command line"); return 0; } + if (argc > 1) { + tgt = argv[1]; + } else { + tgt = get_directory_from_user(); + if (tgt == NULL) goto end; + } + + if (!directory_exists(tgt)) { + show_detailed_error(L"The specified directory does not exist: ", + tgt, 1); + goto end; + } + + // Ensure the path to Calibre Portable is not too long + do { + if (!find_portable_dir(tgt, &dest, &existing)) goto end; + + if (GetFullPathName(dest, MAX_PATH*4, fdest, NULL) == 0) { + show_last_error(L"Failed to resolve target folder"); + goto end; + } + free(dest); dest = NULL; + + if (wcslen(fdest) > 58) { + _snwprintf_s(buf, 4*MAX_PATH, _TRUNCATE, + L"Path to Calibre Portable (%s) too long. Must be less than 59 characters.", fdest); + if (!existing) RemoveDirectory(fdest); + show_error(buf); + tgt = get_directory_from_user(); + if (tgt == NULL) goto end; + } + } while (wcslen(fdest) > 58); + + // Confirm the user wants to upgrade + if (existing) { + _snwprintf_s(mb_msg, 4*MAX_PATH, _TRUNCATE, + L"An existing install of Calibre Portable was found at %s. Do you want to upgrade it?", + fdest); + if (MessageBox(NULL, mb_msg, + L"Upgrade Calibre Portable?", MB_ICONEXCLAMATION | MB_YESNO | MB_TOPMOST) != IDYES) + goto end; + } + + // Make a temp dir to unpack into + if (!SetCurrentDirectoryW(fdest)) { show_detailed_error(L"Failed to change to unzip directory: ", fdest, 0); goto end; } + + if ( (unpack_dir = make_unpack_dir()) == NULL ) goto end; + if (!SetCurrentDirectoryW(unpack_dir)) { show_detailed_error(L"Failed to change to unpack directory: ", fdest, 0); goto end; } + + // Extract files + if (!extract(cdata, csz)) goto end; + + // Move files from temp dir to the install dir + if (!move_program()) goto end; + + SetCurrentDirectoryW(L".."); + + _snwprintf_s(mb_msg, 4*MAX_PATH, _TRUNCATE, + L"Calibre Portable successfully installed to %s. Launch calibre?", + fdest); + launch = MessageBox(NULL, mb_msg, + L"Success", MB_ICONINFORMATION | MB_YESNO | MB_TOPMOST) == IDYES; + +end: + if (unpack_dir != NULL) { rmtree(unpack_dir); free(unpack_dir); } + CoUninitialize(); + if (launch) launch_calibre(); + return 0; +} + + diff --git a/setup/upload.py b/setup/upload.py index f4e8706d1d..e8c44f941e 100644 --- a/setup/upload.py +++ b/setup/upload.py @@ -30,7 +30,7 @@ def installers(): installers = list(map(installer_name, ('dmg', 'msi', 'tar.bz2'))) installers.append(installer_name('tar.bz2', is64bit=True)) installers.insert(0, 'dist/%s-%s.tar.xz'%(__appname__, __version__)) - installers.append('dist/%s-portable-%s.zip'%(__appname__, __version__)) + installers.append('dist/%s-portable-installer-%s.exe'%(__appname__, __version__)) return installers def installer_description(fname): From 95b52a20593341a08bfe0e27ea4c4e64d66780b0 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 16 Sep 2012 14:49:57 +0530 Subject: [PATCH 34/41] Portable installer: Error out if calibre.exe is running --- setup/installer/windows/freeze.py | 4 +- .../installer/windows/portable-installer.cpp | 38 +++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/setup/installer/windows/freeze.py b/setup/installer/windows/freeze.py index ee021b559e..01f4c115d6 100644 --- a/setup/installer/windows/freeze.py +++ b/setup/installer/windows/freeze.py @@ -385,7 +385,7 @@ class Win32Freeze(Command, WixMixIn): zf = self.a(self.j('dist', 'calibre-portable-%s.zip.lz'%VERSION)) usz = os.path.getsize(zf) def cc(src, obj): - cflags = '/c /EHsc /MT /W4 /Ox /nologo /D_UNICODE /DUNICODE'.split() + cflags = '/c /EHsc /MT /W4 /Ox /nologo /D_UNICODE /DUNICODE /DPSAPI_VERSION=1'.split() cflags.append(r'/I%s\include'%LZMA) cflags.append('/DUNCOMPRESSED_SIZE=%d'%usz) if self.newer(obj, [src]): @@ -414,7 +414,7 @@ class Win32Freeze(Command, WixMixIn): desc='Calibre Portable Installer', extra_data=zf, product_description='Calibre Portable Installer'), xobj, obj, 'User32.lib', 'Shell32.lib', 'easylzma_s.lib', - 'Ole32.lib', 'Shlwapi.lib', 'Kernel32.lib'] + 'Ole32.lib', 'Shlwapi.lib', 'Kernel32.lib', 'Psapi.lib'] self.run_builder(cmd) os.remove(zf) diff --git a/setup/installer/windows/portable-installer.cpp b/setup/installer/windows/portable-installer.cpp index 714e9e08b1..3c310a1caf 100644 --- a/setup/installer/windows/portable-installer.cpp +++ b/setup/installer/windows/portable-installer.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -433,6 +434,39 @@ static BOOL move_program() { } // }}} +static BOOL ensure_not_running(LPCWSTR dest) { + DWORD processes[4096], needed, num; + unsigned int i; + WCHAR name[4*MAX_PATH] = L""; + HANDLE h; + DWORD len; + LPWSTR fname = NULL; + + if ( !EnumProcesses( processes, sizeof(processes), &needed ) ) { + return true; + } + num = needed / sizeof(DWORD); + + for (i = 0; i < num; i++) { + if (processes[i] == 0) continue; + h = OpenProcess( PROCESS_QUERY_INFORMATION, FALSE, processes[i] ); + if (h != NULL) { + len = GetProcessImageFileNameW(h, name, 4*MAX_PATH); + CloseHandle(h); + if (len != 0) { + name[len] = 0; + fname = PathFindFileName(name); + if (wcscmp(fname, L"calibre.exe") == 0) { + show_error(L"Calibre appears to be running on your computer. Please quit it before trying to install Calibre Portable."); + return false; + } + } + } + } + + return true; +} + static void launch_calibre() { STARTUPINFO si; PROCESS_INFORMATION pi; @@ -517,6 +551,10 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine goto end; } + if (existing) { + if (!ensure_not_running(fdest)) goto end; + } + // Make a temp dir to unpack into if (!SetCurrentDirectoryW(fdest)) { show_detailed_error(L"Failed to change to unzip directory: ", fdest, 0); goto end; } From 2a7a7cab4cf7a0ffdb55006ccad0bbf6fc1da550 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 16 Sep 2012 15:44:28 +0530 Subject: [PATCH 35/41] Calibre portable: Allow renaming of the 'Calibre Library' folder to something else --- setup/installer/windows/freeze.py | 2 +- setup/installer/windows/portable.c | 43 ++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/setup/installer/windows/freeze.py b/setup/installer/windows/freeze.py index 01f4c115d6..a640a6fcd1 100644 --- a/setup/installer/windows/freeze.py +++ b/setup/installer/windows/freeze.py @@ -442,7 +442,7 @@ class Win32Freeze(Command, WixMixIn): '/RELEASE', '/ENTRY:wWinMainCRTStartup', '/OUT:'+exe, self.embed_resources(exe), - obj, 'User32.lib'] + obj, 'User32.lib', 'Shlwapi.lib'] self.run_builder(cmd) self.info('Creating portable installer') diff --git a/setup/installer/windows/portable.c b/setup/installer/windows/portable.c index a63c319cda..606057432f 100644 --- a/setup/installer/windows/portable.c +++ b/setup/installer/windows/portable.c @@ -8,6 +8,7 @@ #include +#include #include #include #include @@ -134,6 +135,46 @@ void launch_calibre(LPCTSTR exe, LPCTSTR config_dir, LPCTSTR library_dir) { } +static BOOL is_dots(LPCTSTR name) { + return _tcscmp(name, _T(".")) == 0 || _tcscmp(name, _T("..")) == 0; +} + +static void find_calibre_library(LPTSTR library_dir) { + TCHAR base[BUFSIZE] = {0}, buf[BUFSIZE] = {0}; + WIN32_FIND_DATA fdFile; + HANDLE hFind = NULL; + + _sntprintf_s(buf, BUFSIZE, _TRUNCATE, _T("%s\\metadata.db"), base); + + if (PathFileExists(buf)) return; // Calibre Library/metadata.db exists, we use it + + _tcscpy(base, library_dir); + PathRemoveFileSpec(base); + + _sntprintf_s(buf, BUFSIZE, _TRUNCATE, _T("%s\\*"), base); + + // Look for some other folder that contains a metadata.db file inside the Calibre Portable folder + if((hFind = FindFirstFileEx(buf, FindExInfoStandard, &fdFile, FindExSearchLimitToDirectories, NULL, 0)) + != INVALID_HANDLE_VALUE) { + do { + if(is_dots(fdFile.cFileName)) continue; + + if(fdFile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + _sntprintf_s(buf, BUFSIZE, _TRUNCATE, _T("%s\\%s\\metadata.db"), base, fdFile.cFileName); + if (PathFileExists(buf)) { + // some dir/metadata.db exists, we use it as the library + PathRemoveFileSpec(buf); + _tcscpy(library_dir, buf); + FindClose(hFind); + return; + } + } + } while(FindNextFile(hFind, &fdFile)); + FindClose(hFind); + } + +} + int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow) { LPTSTR app_dir, config_dir, exe, library_dir, too_long; @@ -147,6 +188,8 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine _sntprintf_s(exe, BUFSIZE, _TRUNCATE, _T("%sCalibre\\calibre.exe"), app_dir); _sntprintf_s(library_dir, BUFSIZE, _TRUNCATE, _T("%sCalibre Library"), app_dir); + find_calibre_library(library_dir); + if ( _tcscnlen(library_dir, BUFSIZE) <= 74 ) { launch_calibre(exe, config_dir, library_dir); } else { From 03d2b0f606edd75187c05bc19ca638cd8dcc126f Mon Sep 17 00:00:00 2001 From: GRiker Date: Sun, 16 Sep 2012 07:33:45 -0600 Subject: [PATCH 36/41] wip - trying to resolve problems with AZW3 generation --- .../library/catalogs/epub_mobi_builder.py | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/src/calibre/library/catalogs/epub_mobi_builder.py b/src/calibre/library/catalogs/epub_mobi_builder.py index 347c5792be..04e64b9695 100644 --- a/src/calibre/library/catalogs/epub_mobi_builder.py +++ b/src/calibre/library/catalogs/epub_mobi_builder.py @@ -33,6 +33,12 @@ class CatalogBuilder(object): catalog = Catalog(notification=Reporter()) catalog.build_sources() Options managed in gui2.catalog.catalog_epub_mobi.py + + Turned off fetch_bookmarks as of 0.8.70 + self.generate_recently_read = True if (_opts.generate_recently_added and + _opts.connected_kindle and + self.generate_for_kindle_mobi) else False + Does not work with AZW3, interferes with new prefix handling ''' DEBUG = False @@ -85,9 +91,9 @@ class CatalogBuilder(object): @property def SYMBOL_READING(self): if self.generate_for_kindle_mobi: - return self.format_prefix('▷') + return '▷' else: - return self.format_prefix(' ') + return ' ' def __init__(self, db, _opts, plugin, @@ -123,9 +129,7 @@ class CatalogBuilder(object): self.content_dir = os.path.join(self.catalog_path, "content") self.current_step = 0.0 self.error = [] - self.generate_recently_read = True if (_opts.generate_recently_added and - _opts.connected_kindle and - self.generate_for_kindle_mobi) else False + self.generate_recently_read = False self.genres = [] self.genre_tags_dict = None self.html_filelist_1 = [] @@ -959,7 +963,7 @@ class CatalogBuilder(object): """ from calibre.devices.usbms.device import Device - from calibre.devices.kindle.driver import Bookmark + from calibre.devices.kindle.bookmark import Bookmark from calibre.ebooks.metadata import MetaInformation MBP_FORMATS = [u'azw', u'mobi', u'prc', u'txt'] @@ -985,7 +989,10 @@ class CatalogBuilder(object): file_fmts.add(fmt) bookmark_extension = None - if file_fmts.intersection(mbp_formats): + if file_fmts.intersection(han_formats): + book_extension = list(file_fmts.intersection(han_formats))[0] + bookmark_extension = 'han' + elif file_fmts.intersection(mbp_formats): book_extension = list(file_fmts.intersection(mbp_formats))[0] bookmark_extension = 'mbp' elif file_fmts.intersection(tan_formats): @@ -1012,6 +1019,7 @@ class CatalogBuilder(object): path_map.pop(id) return path_map, book_ext + self.bookmarked_books = {} if self.generate_recently_read: self.opts.log.info(" Collecting Kindle bookmarks matching catalog entries") @@ -1046,8 +1054,6 @@ class CatalogBuilder(object): bookmarks[id] = ((myBookmark,book)) self.bookmarked_books = bookmarks - else: - self.bookmarked_books = {} def filter_db_tags(self): """ Remove excluded tags from data set, return normalized genre list. @@ -2849,7 +2855,10 @@ class CatalogBuilder(object): self.update_progress_full_step(_("NCX for Descriptions")) - # --- Construct the 'Books by Title' section --- + sort_descriptions_by = self.books_by_author if self.opts.sort_descriptions_by_author \ + else self.books_by_title + + # --- Construct the 'Descriptions' section --- ncx_soup = self.ncx_soup body = ncx_soup.find("navPoint") btc = len(body.contents) @@ -2858,7 +2867,7 @@ class CatalogBuilder(object): navPointTag = Tag(ncx_soup, 'navPoint') if self.generate_for_kindle_mobi: navPointTag['class'] = "section" - navPointTag['id'] = "bytitle-ID" + navPointTag['id'] = "bydescription-ID" navPointTag['playOrder'] = self.play_order self.play_order += 1 navLabelTag = Tag(ncx_soup, 'navLabel') @@ -2869,13 +2878,11 @@ class CatalogBuilder(object): navPointTag.insert(nptc, navLabelTag) nptc += 1 contentTag = Tag(ncx_soup,"content") - contentTag['src'] = "content/book_%d.html" % int(self.books_by_author[0]['id']) + contentTag['src'] = "content/book_%d.html" % int(sort_descriptions_by[0]['id']) navPointTag.insert(nptc, contentTag) nptc += 1 # Loop over the titles - sort_descriptions_by = self.books_by_author if self.opts.sort_descriptions_by_author \ - else self.books_by_title for book in sort_descriptions_by: navPointVolumeTag = Tag(ncx_soup, 'navPoint') From e0cffc531115c029dadf1397b1b5d45386b2ed46 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 16 Sep 2012 20:13:38 +0530 Subject: [PATCH 37/41] Fix #1051586 (Obsolete links in recipe documentation) --- src/calibre/web/feeds/news.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/calibre/web/feeds/news.py b/src/calibre/web/feeds/news.py index 153c6b1af0..f494618eaa 100644 --- a/src/calibre/web/feeds/news.py +++ b/src/calibre/web/feeds/news.py @@ -453,11 +453,11 @@ class BasicNewsRecipe(Recipe): Override in a subclass to customize extraction of the :term:`URL` that points to the content for each article. Return the article URL. It is called with `article`, an object representing a parsed article - from a feed. See `feedparser `_. + from a feed. See `feedparser `_. By default it looks for the original link (for feeds syndicated via a service like feedburner or pheedo) and if found, returns that or else returns - `article.link `_. + `article.link `_. ''' for key in article.keys(): if key.endswith('_origlink'): From 76c07f7d49efb4c7ac22a756b3402c0be90d3087 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 16 Sep 2012 20:15:52 +0530 Subject: [PATCH 38/41] FC Knudde by drMerry. Fixes #1051577 (FC Knudde new recipe) --- recipes/fc_knudde.recipe | 19 +++++++++++++++++++ recipes/icons/fc_knudde.png | Bin 0 -> 5913 bytes 2 files changed, 19 insertions(+) create mode 100644 recipes/fc_knudde.recipe create mode 100644 recipes/icons/fc_knudde.png diff --git a/recipes/fc_knudde.recipe b/recipes/fc_knudde.recipe new file mode 100644 index 0000000000..8c80f1e949 --- /dev/null +++ b/recipes/fc_knudde.recipe @@ -0,0 +1,19 @@ +from calibre.web.feeds.news import BasicNewsRecipe + +class AdvancedUserRecipe1347706704(BasicNewsRecipe): + title = u'FC Knudde' + __author__ = u'DrMerry' + description = u'FC Knudde de populaire sport strip van Toon van Driel (http://www.toonvandriel.nl)' + language = u'nl' + oldest_article = 7 + max_articles_per_feed = 100 + auto_cleanup = False + cover_url = 'http://a1.mzstatic.com/us/r1000/035/Purple/be/33/70/mzl.qkvshinq.320x480-75.jpg' + no_stylesheets = True + remove_javascript = True + remove_empty_feeds = True + remove_tags_before = dict(id='title') + remove_tags_after = dict(attrs={'class':'entry-content rich-content'}) + use_embedded_content = True + + feeds = [(u'FC Knudde', u'http://www.nusport.nl/feeds/rss/fc-knudde.rss')] diff --git a/recipes/icons/fc_knudde.png b/recipes/icons/fc_knudde.png new file mode 100644 index 0000000000000000000000000000000000000000..4e6f43e278d3dd1de9cbe9faaac01e9c7a866e1b GIT binary patch literal 5913 zcmY*dc{tQx)c=kxi5Tk;8AGy!8B6vojjV~Wi!4L7>||e)kPu@lA&kgU_Q)EBh$%9% zj(utxmPa~C|V139{_>{0U$C40RCN=B3A&w z|KgN2TL4hV0ss!LoF+r13kQw8t|k&7|2OknKBQe(E_-QN_yT}9|9=1lVpX0309&^< zQq9=B(7bT-I%H7?) zqN3u`)xW&59+Qi{OCnf9N{E+ZKFjloN5=x`I^Et+YEu)h@Xg6RMnUKMTxA!pJn)!k zaUV14ukP;1mU5c*IUA@;djL-KoTxuj$xxA8KJ5>GN=~&$Ec9YfY@IK}EPRMtAJHDdE%f}Q=PhA@`!4|hC@|GKvJb@S04DI_AyVXTuQH)yt|EwH|3_b7JX z^GjvKb~neUaWbYd4Zp067fy$D6hR+j>iTqqy*J4lx9@omz8Z;JIBE5J2fv&>^Ij*s zX6ZSg$fNxcj~Wgx?S_ALo_!bd z*}b1|i8o}Wa$-{<;9%pLXS1Qtd5_s6mM*hT=lc!fO$({IOA9no$Rht#{SUs4IT#de zk6^u$Nd__j5z9bs(Ou1A;?`syXSg58 z-o|TWGDw%#x_;~6xl{Q3o_*_rToPu;QWu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+p92?UnA^jQn(3~u$viv-2NwSyL=GL^S~ zv1O8%EtVyO?p;oc21CvDxq!$nCMG`Ueq>$ysd2gefV92iyne*!V3Hz99&4Zg{i#Kh z1IVdTiGXJ1X*eUV>y&Mctj4LbZ8ZtVt{ni?HW`hFGE4_!$JO76lzsMNSY zDYy7(?z&PkQJ_@#qtzXz0D8*rt_LHR9yV|{I{u20bMY@iRy)+5u3cB{%v`1fU0Zv@ z6#Fw0p{hzD@R=r7JR`{a*5t?Sh@e8{%PQe5)`0L#rkskW#T1#ac^~>yp zS?I9<#oLdkfo|1d{lbjrJ+WFK+7}O_Orapk&$KbYajRrtLp*C{Sm$T`#V_v-KMiv~ z2RlDU1+0EfR)N7ej4g1e`K%j2N`OF+me z$jB;4N{hl}E(rgmH1{tE;Qu1HdO12Npgo^>`uKX;p)aD`@;Ax5a61*fi^~A-) lN$jy5+RxJmkPMW(g$P9a2kn2wwHJE Date: Sun, 16 Sep 2012 20:39:16 +0530 Subject: [PATCH 39/41] Disable the start wireless device connection menu item when a wired device is connected --- src/calibre/gui2/actions/device.py | 9 ++++++--- src/calibre/gui2/device.py | 6 ++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/calibre/gui2/actions/device.py b/src/calibre/gui2/actions/device.py index 28b389c625..60fdf531e5 100644 --- a/src/calibre/gui2/actions/device.py +++ b/src/calibre/gui2/actions/device.py @@ -139,10 +139,13 @@ class ShareConnMenu(QMenu): # {{{ def setup_email(self, *args): self.config_email.emit() - def set_state(self, device_connected): + def set_state(self, device_connected, device): self.connect_to_folder_action.setEnabled(not device_connected) self.connect_to_itunes_action.setEnabled(not device_connected) self.connect_to_bambook_action.setEnabled(not device_connected) + enabled = not device_connected or (device_connected and + device.__class__.__name__ == 'SMART_DEVICE_APP') + self.control_smartdevice_action.setEnabled(enabled) # }}} @@ -187,8 +190,8 @@ class ConnectShareAction(InterfaceAction): enabled = loc == 'library' self.qaction.setEnabled(enabled) - def set_state(self, device_connected): - self.share_conn_menu.set_state(device_connected) + def set_state(self, device_connected, device): + self.share_conn_menu.set_state(device_connected, device) def build_email_entries(self): m = self.gui.iactions['Send To Device'].qaction.menu() diff --git a/src/calibre/gui2/device.py b/src/calibre/gui2/device.py index 553532e95d..9299c285d9 100644 --- a/src/calibre/gui2/device.py +++ b/src/calibre/gui2/device.py @@ -929,7 +929,8 @@ class DeviceMixin(object): # {{{ self._sync_menu.fetch_annotations.connect( self.iactions['Fetch Annotations'].fetch_annotations) self._sync_menu.disconnect_mounted_device.connect(self.disconnect_mounted_device) - self.iactions['Connect Share'].set_state(self.device_connected) + self.iactions['Connect Share'].set_state(self.device_connected, + None) if self.device_connected: self._sync_menu.disconnect_mounted_device_action.setEnabled(True) else: @@ -968,7 +969,8 @@ class DeviceMixin(object): # {{{ # Device connected {{{ def set_device_menu_items_state(self, connected): - self.iactions['Connect Share'].set_state(connected) + self.iactions['Connect Share'].set_state(connected, + self.device_manager.device) if connected: self._sync_menu.disconnect_mounted_device_action.setEnabled(True) self._sync_menu.enable_device_actions(True, From fa1122a39c67fe99bccf79605616902cf9ff6f32 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 16 Sep 2012 21:06:41 +0530 Subject: [PATCH 40/41] Output platform info during device debug --- src/calibre/devices/__init__.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/calibre/devices/__init__.py b/src/calibre/devices/__init__.py index 2c1d628566..9fa0ab355c 100644 --- a/src/calibre/devices/__init__.py +++ b/src/calibre/devices/__init__.py @@ -62,7 +62,7 @@ def debug(ioreg_to_tmp=False, buf=None, plugins=None): already have been called (for example in the main GUI), pass in the list of device plugins as the plugins parameter. ''' - import textwrap + import textwrap, platform from calibre.customize.ui import device_plugins from calibre.devices.scanner import DeviceScanner, win_pnp_drives from calibre.constants import iswindows, isosx, __version__ @@ -85,7 +85,21 @@ def debug(ioreg_to_tmp=False, buf=None, plugins=None): out('Startup failed for device plugin: %s'%d) try: - out('Version:', __version__) + out('Calibre Version:', __version__) + out(platform.platform(), platform.system()) + out(platform.system_alias(platform.system(), platform.release(), + platform.version())) + out('Python', platform.python_version()) + try: + if iswindows: + out('Windows:', platform.win32_ver()) + elif isosx: + out('OSX:', platform.mac_ver()) + else: + out('Linux:', platform.linux_distribution()) + except: + pass + s = DeviceScanner() s.scan() devices = (s.devices) From d9ff4ded40c38dd18cba7cb82463d085cec3f8d4 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 16 Sep 2012 22:40:47 +0530 Subject: [PATCH 41/41] Revert disabling of wireless device driver menu entry --- src/calibre/gui2/actions/device.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/calibre/gui2/actions/device.py b/src/calibre/gui2/actions/device.py index 60fdf531e5..5ab56121c1 100644 --- a/src/calibre/gui2/actions/device.py +++ b/src/calibre/gui2/actions/device.py @@ -143,9 +143,6 @@ class ShareConnMenu(QMenu): # {{{ self.connect_to_folder_action.setEnabled(not device_connected) self.connect_to_itunes_action.setEnabled(not device_connected) self.connect_to_bambook_action.setEnabled(not device_connected) - enabled = not device_connected or (device_connected and - device.__class__.__name__ == 'SMART_DEVICE_APP') - self.control_smartdevice_action.setEnabled(enabled) # }}}