-
- // TODO: ask client if ok or to change it herself
-
- String serverLastModifTime = updateToServer(s, original,
- merge);
+ List<Contact> added = new LinkedList<Contact>();
+ List<Contact> removed = new LinkedList<Contact>();
+ original.compare(local, added, removed, removed, added);
+ for (Contact c : removed)
+ merge.getById(c.getId()).delete();
+ for (Contact c : added)
+ merge.add(Vcard21Parser.clone(c));
+
+ merge.save();
+
+ // defer to client:
+ if (callback == null) {
+ throw new IOException(
+ "Conflicting changes detected and merge operation not allowed");
+ }
+
+ merge = callback.merge(original, local, server, merge);
+ if (merge == null) {
+ throw new IOException(
+ "Conflicting changes detected and merge operation cancelled");
+ }
+
+ // TODO: something like:
+ // String serverLastModifTime = updateToServer(s, original,
+ // merge);
+ // ...but without starting with original since it is not
+ // true here
+ s.sendCommand(Command.POST_CARD);
+ s.sendBlock(Vcard21Parser.toStrings(merge));
+ String serverLastModifTime = s.receiveLine();
+ //