[libe-book] detect and parse zipped FictionBook 2 files again

David Tardon dtardon at fedoraproject.org
Thu May 29 11:43:56 UTC 2014


commit f7a5844a1a3717a471510d8eaad57b7651c0dfc4
Author: David Tardon <dtardon at redhat.com>
Date:   Thu May 29 13:39:42 2014 +0200

    detect and parse zipped FictionBook 2 files again

 0001-parse-zipped-FictionBook-2-files-again.patch |   58 +++++++++++++++++++++
 libe-book.spec                                    |    6 ++-
 2 files changed, 63 insertions(+), 1 deletions(-)
---
diff --git a/0001-parse-zipped-FictionBook-2-files-again.patch b/0001-parse-zipped-FictionBook-2-files-again.patch
new file mode 100644
index 0000000..d068e79
--- /dev/null
+++ b/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 at 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/libe-book.spec b/libe-book.spec
index 4cd5f32..e714f90 100644
--- a/libe-book.spec
+++ b/libe-book.spec
@@ -2,7 +2,7 @@
 
 Name: libe-book
 Version: 0.1.0
-Release: 1%{?dist}
+Release: 2%{?dist}
 Summary: A library for import of reflowable e-book formats
 
 Group: System Environment/Libraries
@@ -22,6 +22,7 @@ BuildRequires: pkgconfig(zlib)
 
 Patch0: 0001-libcss-et-al.-are-not-required-for-standard-build.patch
 Patch1: 0002-HTML-based-formats-are-not-supported-yet.patch
+Patch2: 0001-parse-zipped-FictionBook-2-files-again.patch
 
 %description
 %{name} is a library for import of reflowable e-book formats.
@@ -113,6 +114,9 @@ make %{?_smp_mflags} check
 %{_mandir}/man1/ebook2text.1*
 
 %changelog
+* Thu May 29 2014 David Tardon <dtardon at redhat.com> - 0.1.0-2
+- detect and parse zipped FictionBook 2 files again
+
 * Mon May 26 2014 David Tardon <dtardon at redhat.com> - 0.1.0-1
 - new upstream release 0.1.0
 


More information about the scm-commits mailing list