Remoting: lot of fixes
[jvcard.git] / src / be / nikiroo / jvcard / launcher / Main.java
index b0e3bd80ca43ffbb69247132ccb2c581fcd7b3cb..925ade4a4e23a0133385162cf4a03297a0fca5de 100644 (file)
@@ -12,7 +12,7 @@ import java.util.List;
 
 import be.nikiroo.jvcard.Card;
 import be.nikiroo.jvcard.parsers.Format;
-import be.nikiroo.jvcard.remote.Command.Verb;
+import be.nikiroo.jvcard.remote.Command;
 import be.nikiroo.jvcard.remote.SimpleSocket;
 import be.nikiroo.jvcard.resources.Bundles;
 import be.nikiroo.jvcard.resources.StringUtils;
@@ -211,8 +211,7 @@ public class Main {
                                        System.err
                                                        .println("I/O Exception: Cannot start the server");
                                } else {
-                                       System.err.println("FATAL ERROR");
-                                       e.printStackTrace();
+                                       System.err.println("Remoting support not available");
                                        System.exit(ERR_INTERNAL);
                                }
                        }
@@ -232,8 +231,7 @@ public class Main {
                                        System.err
                                                        .println("I/O Exception: Cannot start the program with the given cards");
                                } else {
-                                       System.err.println("FATAL ERROR");
-                                       e.printStackTrace();
+                                       System.err.println("TUI support not available");
                                        System.exit(ERR_INTERNAL);
                                }
                        }
@@ -279,7 +277,7 @@ public class Main {
                } catch (IOException ioe) {
                        throw ioe;
                } catch (Exception e) {
-                       throw new IOException("Remoting not available", e);
+                       throw new IOException("Remoting support not available", e);
                }
 
                return card;
@@ -391,17 +389,11 @@ public class Main {
                        InvocationTargetException, IOException {
                @SuppressWarnings("rawtypes")
                Class syncClass = Class.forName("be.nikiroo.jvcard.remote.Sync");
-               Method getCache = syncClass.getDeclaredMethod("getCache",
-                               new Class[] {});
-               Method sync = syncClass.getDeclaredMethod("sync", new Class[] {
-                               Card.class, boolean.class });
+               Method sync = syncClass.getDeclaredMethod("sync",
+                               new Class[] { boolean.class });
 
                Object o = syncClass.getConstructor(String.class).newInstance(input);
-
-               File file = (File) getCache.invoke(o);
-               Card card = new Card(file, Format.VCard21);
-               card.setRemote(true);
-               sync.invoke(o, card, false);
+               Card card = (Card) sync.invoke(o, false);
 
                return card;
        }
@@ -465,7 +457,7 @@ public class Main {
                                        "sync client");
                        s.open(true);
 
-                       s.sendCommand(Verb.LIST);
+                       s.sendCommand(Command.LIST_CARD);
                        for (String p : s.receiveBlock()) {
                                files.add(path
                                                + p.substring(StringUtils.fromTime(0).length() + 1));