X-Git-Url: http://git.nikiroo.be/?p=fanfix.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Freader%2FLocalReader.java;fp=src%2Fbe%2Fnikiroo%2Ffanfix%2Freader%2FLocalReader.java;h=0000000000000000000000000000000000000000;hp=593f58b2122685034d3ad7b34e4c230467e1ed0f;hb=5dd985cf7d5e2bb88b07fd43e7b4a4eda4647181;hpb=68e2c6d20049d713de1bd31b749450b2f60d8340
diff --git a/src/be/nikiroo/fanfix/reader/LocalReader.java b/src/be/nikiroo/fanfix/reader/LocalReader.java
deleted file mode 100644
index 593f58b..0000000
--- a/src/be/nikiroo/fanfix/reader/LocalReader.java
+++ /dev/null
@@ -1,236 +0,0 @@
-package be.nikiroo.fanfix.reader;
-
-import java.awt.Desktop;
-import java.awt.EventQueue;
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
-
-import javax.swing.JEditorPane;
-import javax.swing.JLabel;
-import javax.swing.JOptionPane;
-import javax.swing.event.HyperlinkEvent;
-import javax.swing.event.HyperlinkListener;
-
-import be.nikiroo.fanfix.Instance;
-import be.nikiroo.fanfix.LocalLibrary;
-import be.nikiroo.fanfix.VersionCheck;
-import be.nikiroo.fanfix.bundles.UiConfig;
-import be.nikiroo.fanfix.data.Story;
-import be.nikiroo.fanfix.output.BasicOutput.OutputType;
-import be.nikiroo.utils.Progress;
-import be.nikiroo.utils.Version;
-import be.nikiroo.utils.ui.UIUtils;
-
-class LocalReader extends BasicReader {
- static private boolean nativeLookLoaded;
-
- private LocalLibrary localLibrary;
-
- public LocalReader() throws IOException {
- if (!nativeLookLoaded) {
- UIUtils.setLookAndFeel();
- nativeLookLoaded = true;
- }
-
- File dir = Instance.getReaderDir();
- dir.mkdirs();
- if (!dir.exists()) {
- throw new IOException(
- "Cannote create cache directory for local reader: " + dir);
- }
-
- OutputType text = null;
- OutputType images = null;
-
- try {
- text = OutputType.valueOfNullOkUC(Instance.getUiConfig().getString(
- UiConfig.NON_IMAGES_DOCUMENT_TYPE));
- if (text == null) {
- text = OutputType.HTML;
- }
-
- images = OutputType.valueOfNullOkUC(Instance.getUiConfig()
- .getString(UiConfig.IMAGES_DOCUMENT_TYPE));
- if (images == null) {
- images = OutputType.CBZ;
- }
- } catch (Exception e) {
- UiConfig key = (text == null) ? UiConfig.NON_IMAGES_DOCUMENT_TYPE
- : UiConfig.IMAGES_DOCUMENT_TYPE;
- String value = Instance.getUiConfig().getString(key);
-
- throw new IOException(
- String.format(
- "The configuration option %s is not valid: %s",
- key, value), e);
- }
-
- localLibrary = new LocalLibrary(dir, text, images);
- }
-
- @Override
- public void read() throws IOException {
- if (getStory() == null) {
- throw new IOException("No story to read");
- }
-
- open(getStory().getMeta().getLuid(), null);
- }
-
- @Override
- public void read(int chapter) throws IOException {
- // TODO: show a special page?
- read();
- }
-
- /**
- * 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 {
- Progress pgGetStory = new Progress();
- Progress pgSave = new Progress();
- if (pg != null) {
- pg.setMax(2);
- pg.addProgress(pgGetStory, 1);
- pg.addProgress(pgSave, 1);
- }
-
- try {
- Story story = Instance.getLibrary().getStory(luid, pgGetStory);
- if (story != null) {
- story = localLibrary.save(story, luid, pgSave);
- } else {
- throw new IOException("Cannot find story in Library: " + luid);
- }
- } catch (IOException e) {
- throw new IOException(
- "Cannot import story from library to LocalReader library: "
- + luid, e);
- }
- }
-
- /**
- * Check if the {@link Story} denoted by this Library UID is present in the
- * {@link LocalReader} cache.
- *
- * @param luid
- * the Library UID
- *
- * @return TRUE if it is
- */
- public boolean isCached(String luid) {
- return localLibrary.getInfo(luid) != null;
- }
-
- @Override
- public void browse(String type) {
- // TODO: improve presentation of update message
- final VersionCheck updates = VersionCheck.check();
- StringBuilder builder = new StringBuilder();
-
- final JEditorPane updateMessage = new JEditorPane("text/html", "");
- if (updates.isNewVersionAvailable()) {
- builder.append("A new version of the program is available at https://github.com/nikiroo/fanfix/releases");
- builder.append("
");
- builder.append("
");
- for (Version v : updates.getNewer()) {
- builder.append("\tVersion " + v + "");
- builder.append("
");
- builder.append("