summaryrefslogtreecommitdiff
path: root/external/libebook
diff options
context:
space:
mode:
authorDavid Tardon <dtardon@redhat.com>2014-05-29 13:31:54 +0200
committerDavid Tardon <dtardon@redhat.com>2014-05-29 13:33:50 +0200
commit2ac1d3949c383656e54d54556e52631cf4f45b71 (patch)
treee65072326b4405867a6e1dcbec657b34db4d26a2 /external/libebook
parent5fde8e38c127a872a66b8029b69aff55b01d6d88 (diff)
parse zipped FictionBook 2 files again
Change-Id: I04eda7844a5557f834f3ada2cef991b0a181c8a0
Diffstat (limited to 'external/libebook')
-rw-r--r--external/libebook/0001-parse-zipped-FictionBook-2-files-again.patch58
-rw-r--r--external/libebook/UnpackedTarball_libebook.mk1
2 files changed, 59 insertions, 0 deletions
diff --git a/external/libebook/0001-parse-zipped-FictionBook-2-files-again.patch b/external/libebook/0001-parse-zipped-FictionBook-2-files-again.patch
new file mode 100644
index 000000000000..d068e798fe8f
--- /dev/null
+++ b/external/libebook/0001-parse-zipped-FictionBook-2-files-again.patch
@@ -0,0 +1,58 @@
+From 5690c18cb2de1bf4f3cce3da8a2132303a0c731f Mon Sep 17 00:00:00 2001
+From: David Tardon <dtardon@redhat.com>
+Date: Thu, 29 May 2014 13:30:13 +0200
+Subject: [PATCH] parse zipped FictionBook 2 files again
+
+---
+ src/lib/EBOOKDocument.cpp | 28 +++++++++++++++++++++++++++-
+ 1 file changed, 27 insertions(+), 1 deletion(-)
+
+diff --git a/src/lib/EBOOKDocument.cpp b/src/lib/EBOOKDocument.cpp
+index 5b8e7ec..c4f9913 100644
+--- a/src/lib/EBOOKDocument.cpp
++++ b/src/lib/EBOOKDocument.cpp
+@@ -427,6 +427,25 @@ EBOOKAPI EBOOKDocument::Confidence EBOOKDocument::isSupported(librevenge::RVNGIn
+ }
+ }
+ #endif
++
++ // TODO: This needs improvement: zipped FictionBook 2 files can contain images too...
++ if (1 == input->subStreamCount())
++ {
++ const librevenge::RVNGString name(input->subStreamName(0));
++ const unsigned long size = name.size();
++ const char *const cName = name.cstr();
++ if (equal(cName + (size - 4), cName + size, ".fb2"))
++ {
++ const scoped_ptr<RVNGInputStream> fb2(input->getSubStreamById(0));
++ const Type xmlType = detectXML(fb2.get());
++ if (TYPE_FICTIONBOOK2 == xmlType)
++ {
++ if (type)
++ *type = xmlType;
++ return CONFIDENCE_EXCELLENT;
++ }
++ }
++ }
+ }
+
+ Confidence confidence = CONFIDENCE_NONE;
+@@ -533,7 +552,14 @@ EBOOKAPI EBOOKDocument::Result EBOOKDocument::parse(librevenge::RVNGInputStream
+ #endif
+ case TYPE_FICTIONBOOK2 :
+ {
+- FB2Parser parser(input_.get());
++ RVNGInputStreamPtr_t fb2Input(input_);
++ // TODO: this needs to handle package with images too
++ if (input_->isStructured())
++ {
++ assert(1 == input->subStreamCount());
++ fb2Input.reset(input->getSubStreamById(0));
++ }
++ FB2Parser parser(fb2Input.get());
+ return parser.parse(document) ? RESULT_OK : RESULT_UNKNOWN_ERROR;
+ }
+ #if defined ENABLE_EXPERIMENTAL
+--
+1.9.3
+
diff --git a/external/libebook/UnpackedTarball_libebook.mk b/external/libebook/UnpackedTarball_libebook.mk
index bcc098a6643e..498698102a34 100644
--- a/external/libebook/UnpackedTarball_libebook.mk
+++ b/external/libebook/UnpackedTarball_libebook.mk
@@ -15,6 +15,7 @@ $(eval $(call gb_UnpackedTarball_set_patchlevel,libebook,1))
$(eval $(call gb_UnpackedTarball_add_patches,libebook,\
external/libebook/0001-blind-attempt-to-workaround-MSVC-bug.patch \
+ external/libebook/0001-parse-zipped-FictionBook-2-files-again.patch \
))
# vim: set noet sw=4 ts=4: