+ case PUT_CARD:
+ List<Contact> added = new LinkedList<Contact>();
+ List<Contact> removed = new LinkedList<Contact>();
+ List<Contact> from = new LinkedList<Contact>();
+ List<Contact> to = new LinkedList<Contact>();
+ original.compare(local, added, removed, from, to);
+ s.sendCommand(Verb.PUT_CARD, name);
+ for (Contact c : removed) {
+ s.sendCommand(Verb.DELETE_CONTACT, c.getId());
+ }
+ for (Contact c : added) {
+ s.sendCommand(Verb.POST_CONTACT, c.getId());
+ s.sendBlock(Vcard21Parser.toStrings(c, -1));
+ }
+ if (from.size() > 0) {
+ for (int index = 0; index < from.size(); index++) {
+ Contact f = from.get(index);
+ Contact t = to.get(index);
+
+ List<Data> subadded = new LinkedList<Data>();
+ List<Data> subremoved = new LinkedList<Data>();
+ f.compare(t, subadded, subremoved, subremoved, subadded);
+ s.sendCommand(Verb.PUT_CONTACT, name);
+ for (Data d : subremoved) {
+ s.sendCommand(Verb.DELETE_DATA, d.getContentState());
+ }
+ for (Data d : subadded) {
+ s.sendCommand(Verb.POST_DATA, d.getContentState());
+ s.sendBlock(Vcard21Parser.toStrings(d));
+ }
+ }
+ }
+ s.sendCommand(Verb.PUT_CARD);
+ break;