+ private void createConfigs(String configDir, boolean refresh) {
+ if (!refresh) {
+ Bundles.setDirectory(configDir);
+ }
+
+ try {
+ config = new ConfigBundle();
+ config.updateFile(configDir);
+ } catch (IOException e) {
+ tracer.error(e);
+ }
+
+ try {
+ uiconfig = new UiConfigBundle();
+ uiconfig.updateFile(configDir);
+ } catch (IOException e) {
+ tracer.error(e);
+ }
+
+ // No updateFile for this one! (we do not want the user to have custom
+ // translations that won't accept updates from newer versions)
+ trans = new StringIdBundle(getLang());
+ transGui = new StringIdGuiBundle(getLang());
+
+ // Fix an old bug (we used to store custom translation files by
+ // default):
+ if (trans.getString(StringId.INPUT_DESC_CBZ) == null) {
+ trans.deleteFile(configDir);
+ }
+
+ Boolean noutf = checkEnv("NOUTF");
+ if (noutf != null && noutf) {
+ trans.setUnicode(false);
+ transGui.setUnicode(false);
+ }
+
+ Bundles.setDirectory(configDir);
+ }
+
+ /**
+ * Create the default library as specified by the config.
+ *
+ * @param remoteDir
+ * the base remote directory if needed
+ *
+ * @return the default {@link BasicLibrary}
+ */
+ private BasicLibrary createDefaultLibrary(File remoteDir) {
+ BasicLibrary lib = null;
+
+ boolean useRemote = config.getBoolean(Config.REMOTE_LIBRARY_ENABLED,
+ false);
+ if (useRemote) {
+ String host = null;
+ int port = -1;
+ try {
+ host = config.getString(Config.REMOTE_LIBRARY_HOST,
+ "fanfix://localhost");
+ port = config.getInteger(Config.REMOTE_LIBRARY_PORT, -1);
+ String key = config.getString(Config.REMOTE_LIBRARY_KEY);
+
+ if (!host.startsWith("http://") && !host.startsWith("https://")
+ && !host.startsWith("fanfix://")) {
+ host = "fanfix://" + host;
+ }
+
+ tracer.trace("Selecting remote library " + host + ":" + port);
+
+ if (host.startsWith("fanfix://")) {
+ lib = new RemoteLibrary(key, host, port);
+ } else {
+ lib = new WebLibrary(key, host, port);
+ }
+
+ lib = new CacheLibrary(getRemoteDir(remoteDir, host), lib,
+ uiconfig);
+ } catch (Exception e) {
+ tracer.error(
+ new IOException("Cannot create remote library for: "
+ + host + ":" + port, e));
+ }