Small fixes: update check, epub:
[fanfix.git] / src / be / nikiroo / fanfix / supported / Epub.java
index 437197a5a66cb12cee19a05ef192e9d35622494d..bd5c7191a86fe687942a6411c4291ff9010ad060 100644 (file)
@@ -15,7 +15,9 @@ import java.util.zip.ZipInputStream;
 import be.nikiroo.fanfix.Instance;
 import be.nikiroo.fanfix.data.MetaData;
 import be.nikiroo.utils.IOUtils;
+import be.nikiroo.utils.ImageUtils;
 import be.nikiroo.utils.MarkableFileInputStream;
+import be.nikiroo.utils.Progress;
 
 /**
  * Support class for EPUB files created with this program (as we need some
@@ -60,22 +62,22 @@ class Epub extends InfoText {
        }
 
        @Override
-       protected List<Entry<String, URL>> getChapters(URL source, InputStream in)
-                       throws IOException {
+       protected List<Entry<String, URL>> getChapters(URL source, InputStream in,
+                       Progress pg) throws IOException {
                if (fakeIn != null) {
                        fakeIn.reset();
-                       return super.getChapters(fakeSource, fakeIn);
+                       return super.getChapters(fakeSource, fakeIn, pg);
                }
 
                return null;
        }
 
        @Override
-       protected String getChapterContent(URL source, InputStream in, int number)
-                       throws IOException {
+       protected String getChapterContent(URL source, InputStream in, int number,
+                       Progress pg) throws IOException {
                if (fakeIn != null) {
                        fakeIn.reset();
-                       return super.getChapterContent(fakeSource, fakeIn, number);
+                       return super.getChapterContent(fakeSource, fakeIn, number, pg);
                }
 
                return null;
@@ -95,7 +97,7 @@ class Epub extends InfoText {
                        if (!entry.isDirectory()
                                        && entry.getName().startsWith(getDataPrefix())) {
                                String entryLName = entry.getName().toLowerCase();
-
+                               
                                boolean imageEntry = false;
                                for (String ext : getImageExt(false)) {
                                        if (entryLName.endsWith(ext)) {
@@ -113,7 +115,7 @@ class Epub extends InfoText {
                                        // Cover
                                        if (getCover()) {
                                                try {
-                                                       cover = IOUtils.toImage(zipIn);
+                                                       cover = ImageUtils.fromStream(zipIn);
                                                } catch (Exception e) {
                                                        Instance.syserr(e);
                                                }
@@ -139,7 +141,7 @@ class Epub extends InfoText {
                }
 
                if (tmpInfo.exists()) {
-                       meta = InfoReader.readMeta(tmpInfo);
+                       meta = InfoReader.readMeta(tmpInfo, true);
                        if (cover != null) {
                                meta.setCover(cover);
                        }
@@ -164,7 +166,10 @@ class Epub extends InfoText {
 
                tmp = null;
 
-               fakeIn.close();
+               if (fakeIn != null) {
+                       fakeIn.close();
+               }
+
                super.close();
        }