X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2FMain.java;h=0974392df9826a90b4a3dd3a6520ca52d5a1bd67;hb=69f4b58e3fe56b682792393be646c1df46c86ae1;hp=f8c0ca25f486b3d0f082bf0874cd6689d26bf42b;hpb=fb25273cf02653ac343d5437083b1bc41af5ce23;p=fanfix.git diff --git a/src/be/nikiroo/fanfix/Main.java b/src/be/nikiroo/fanfix/Main.java index f8c0ca2..0974392 100644 --- a/src/be/nikiroo/fanfix/Main.java +++ b/src/be/nikiroo/fanfix/Main.java @@ -7,8 +7,12 @@ import java.net.URL; import java.util.ArrayList; import java.util.List; +import javax.net.ssl.SSLException; + import be.nikiroo.fanfix.bundles.Config; +import be.nikiroo.fanfix.bundles.ConfigBundle; import be.nikiroo.fanfix.bundles.StringId; +import be.nikiroo.fanfix.bundles.StringIdBundle; import be.nikiroo.fanfix.data.Chapter; import be.nikiroo.fanfix.data.MetaData; import be.nikiroo.fanfix.data.Story; @@ -27,6 +31,8 @@ import be.nikiroo.fanfix.supported.BasicSupport; import be.nikiroo.fanfix.supported.SupportType; import be.nikiroo.utils.Progress; import be.nikiroo.utils.Version; +import be.nikiroo.utils.resources.Bundles; +import be.nikiroo.utils.resources.TransBundle; import be.nikiroo.utils.serial.server.ServerObject; /** @@ -86,6 +92,9 @@ public class Main { * see method description */ public static void main(String[] args) { + // Only one line, but very important: + Instance.init(); + String urlString = null; String luid = null; String sourceString = null; @@ -564,7 +573,12 @@ public class Main { exitCode = 10; break; } - BasicReader.getReader().browse(null); + try { + BasicReader.getReader().browse(null); + } catch (IOException e) { + Instance.getTraceHandler().error(e); + exitCode = 66; + } break; case SERVER: key = Instance.getConfig().getString(Config.SERVER_KEY); @@ -590,8 +604,17 @@ public class Main { exitCode = 15; break; } + try { + new RemoteLibrary(key, host, port).exit(); + } catch (SSLException e) { + Instance.getTraceHandler().error( + "Bad access key for remote library"); + exitCode = 43; + } catch (IOException e) { + Instance.getTraceHandler().error(e); + exitCode = 44; + } - new RemoteLibrary(key, host, port).exit(); break; case REMOTE: exitCode = 255; // should not be reachable (REMOTE -> START) @@ -626,10 +649,10 @@ public class Main { */ public static int imprt(String urlString, Progress pg) { try { - Story story = Instance.getLibrary().imprt( + MetaData meta = Instance.getLibrary().imprt( BasicReader.getUrl(urlString), pg); - System.out.println(story.getMeta().getLuid() + ": \"" - + story.getMeta().getTitle() + "\" imported."); + System.out.println(meta.getLuid() + ": \"" + meta.getTitle() + + "\" imported."); } catch (IOException e) { Instance.getTraceHandler().error(e); return 1; @@ -683,18 +706,14 @@ public class Main { * @return the exit return code (0 = success) */ private static int list(String source) { - List stories; - stories = BasicReader.getReader().getLibrary().getListBySource(source); - - for (MetaData story : stories) { - String author = ""; - if (story.getAuthor() != null && !story.getAuthor().isEmpty()) { - author = " (" + story.getAuthor() + ")"; - } - - System.out.println(story.getLuid() + ": " + story.getTitle() - + author); + BasicReader.setDefaultReaderType(ReaderType.CLI); + try { + BasicReader.getReader().browse(source); + } catch (IOException e) { + Instance.getTraceHandler().error(e); + return 66; } + return 0; }