X-Git-Url: http://git.nikiroo.be/?p=fanfix.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Freader%2FLocalReader.java;h=88ffc5d42d534dbbfbf1fa7d89c8de310ec4d79a;hp=86b779c343c0b964d9c80d96493ccd47ec02f7d5;hb=92fb0719f84f5b6734b51e528332546d78e9ccec;hpb=3d247bc3bb955a9b85686f0db431157cb9dc4a10 diff --git a/src/be/nikiroo/fanfix/reader/LocalReader.java b/src/be/nikiroo/fanfix/reader/LocalReader.java index 86b779c..88ffc5d 100644 --- a/src/be/nikiroo/fanfix/reader/LocalReader.java +++ b/src/be/nikiroo/fanfix/reader/LocalReader.java @@ -6,10 +6,10 @@ import java.io.IOException; import be.nikiroo.fanfix.Instance; import be.nikiroo.fanfix.Library; -import be.nikiroo.fanfix.bundles.Config; -import be.nikiroo.fanfix.data.MetaData; +import be.nikiroo.fanfix.bundles.UiConfig; import be.nikiroo.fanfix.data.Story; import be.nikiroo.fanfix.output.BasicOutput.OutputType; +import be.nikiroo.utils.ui.Progress; class LocalReader extends BasicReader { private Library lib; @@ -23,14 +23,14 @@ class LocalReader extends BasicReader { } // TODO: can throw an exception, manage that (convert to IOEx ?) - OutputType text = OutputType.valueOfNullOkUC(Instance.getConfig() - .getString(Config.LOCAL_READER_NON_IMAGES_DOCUMENT_TYPE)); + OutputType text = OutputType.valueOfNullOkUC(Instance.getUiConfig() + .getString(UiConfig.LOCAL_READER_NON_IMAGES_DOCUMENT_TYPE)); if (text == null) { text = OutputType.HTML; } - OutputType images = OutputType.valueOfNullOkUC(Instance.getConfig() - .getString(Config.LOCAL_READER_IMAGES_DOCUMENT_TYPE)); + OutputType images = OutputType.valueOfNullOkUC(Instance.getUiConfig() + .getString(UiConfig.LOCAL_READER_IMAGES_DOCUMENT_TYPE)); if (images == null) { images = OutputType.CBZ; } @@ -47,13 +47,22 @@ class LocalReader extends BasicReader { public void read(int chapter) { } - // return new luid - public String imprt(String luid) throws IOException { + /** + * Import the story into the local reader library, and keep the same LUID. + * + * @param luid + * the Library UID + * @param pg + * the optional progress reporter + * + * @throws IOException + * in case of I/O error + */ + public void imprt(String luid, Progress pg) throws IOException { try { - Story story = Instance.getLibrary().getStory(luid); + Story story = Instance.getLibrary().getStory(luid, pg); if (story != null) { - story = lib.save(story); - return story.getMeta().getLuid(); + story = lib.save(story, luid); } else { throw new IOException("Cannot find story in Library: " + luid); } @@ -64,13 +73,24 @@ class LocalReader extends BasicReader { } } - public File getTarget(String luid) throws IOException { - MetaData meta = lib.getInfo(luid); + /** + * Get the target file related to this {@link Story}. + * + * @param luid + * the LUID of the {@link Story} + * @param pg + * the optional progress reporter + * + * @return the target file + * + * @throws IOException + * in case of I/O error + */ + public File getTarget(String luid, Progress pg) throws IOException { File file = lib.getFile(luid); if (file == null) { - luid = imprt(luid); + imprt(luid, pg); file = lib.getFile(luid); - meta = lib.getInfo(luid); } return file;