X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Fjvcard%2Flauncher%2FMain.java;h=f96e5581b05f99c12f69c3af4603284f4065815f;hb=99f631de95f8b89bd716b8c4011308fc1aacaeaf;hp=85223d878560efb1d5dc55a8e6d9f5b781a8639f;hpb=88eb81220498dc5b3199bad2d1de6970b55ceaed;p=jvcard.git diff --git a/src/be/nikiroo/jvcard/launcher/Main.java b/src/be/nikiroo/jvcard/launcher/Main.java index 85223d8..f96e558 100644 --- a/src/be/nikiroo/jvcard/launcher/Main.java +++ b/src/be/nikiroo/jvcard/launcher/Main.java @@ -37,7 +37,7 @@ import be.nikiroo.jvcard.resources.enums.StringId; */ public class Main { static public final String APPLICATION_TITLE = "jVcard"; - static public final String APPLICATION_VERSION = "1.0"; + static public final String APPLICATION_VERSION = "1.0-dev"; static private final int ERR_NO_FILE = 1; static private final int ERR_SYNTAX = 2; @@ -63,7 +63,7 @@ public class Main { * @return the translated text with the given value where required */ static public String trans(StringId id, Object... values) { - return transService.getString(id, (Object[]) values); + return transService.getString(id, values); } /** @@ -278,6 +278,7 @@ public class Main { new RemoteBundle().updateFile(dir); } catch (IOException e) { e.printStackTrace(); + System.err.flush(); System.exit(ERR_INTERNAL); } break; @@ -316,9 +317,17 @@ public class Main { File f = new File(dir, filename); if (f.exists()) { + System.out.println("Loading " + f); try { - String b64 = StringUtils.fromImage(ImageIO - .read(f)); + String type = "jpeg"; + int dotIndex = filename.indexOf('.'); + if (dotIndex >= 0 + && (dotIndex + 1) < filename.length()) { + type = filename.substring(dotIndex + 1) + .toLowerCase(); + } + + String b64 = StringUtils.fromImage(f); // remove previous photos: for (Data photo = contact @@ -330,7 +339,7 @@ public class Main { List types = new LinkedList(); types.add(new TypeInfo("ENCODING", "b")); - types.add(new TypeInfo("TYPE", "png")); + types.add(new TypeInfo("TYPE", type)); Data photo = new Data(types, "PHOTO", b64, null); contact.add(photo); } catch (IOException e) { @@ -356,6 +365,7 @@ public class Main { if (photo != null) { String filename = contact.toString(format, ""); File f = new File(dir, filename + ".png"); + System.out.println("Saving " + f); try { ImageIO.write( StringUtils.toImage(photo.getValue()), @@ -419,7 +429,8 @@ public class Main { + trans(StringId.CLI_HELP_LANG)); System.out.println("\t--tui : " + trans(StringId.CLI_HELP_TUI)); System.out.println("\t--gui : " + trans(StringId.CLI_HELP_GUI)); - System.out.println("\t--noutf : " + trans(StringId.CLI_HELP_NOUTF)); + System.out.println("\t--noutf : " + + trans(StringId.CLI_HELP_NOUTF_OPTION)); System.out.println("\t--config : " + trans(StringId.CLI_HELP_CONFIG)); System.out.println(); @@ -490,7 +501,7 @@ public class Main { Data name = contact.getPreferredData("FN"); if (name == null || name.getValue().length() == 0 || forceComputedFn) { - name.setValue(contact.toString(defaultFn, "")); + name.setValue(contact.toString(defaultFn, "").trim()); } } } catch (Exception e) { @@ -630,6 +641,7 @@ public class Main { else System.err.println(trans(err, trans(suberr, subvalues))); + System.err.flush(); System.exit(CODE); } }