X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Fjvcard%2Fremote%2FSync.java;h=4b7a18bdec3c7353f12d4e6f5b0349c8287c2a4c;hb=f06c81000632cfb5f525ca458f719338f55f9f66;hp=609041eaaceef39e449df33a7d85781b99f6c2ab;hpb=e119a1c1a924998b9315e46c96b1c750aab1deb9;p=jvcard.git diff --git a/src/be/nikiroo/jvcard/remote/Sync.java b/src/be/nikiroo/jvcard/remote/Sync.java index 609041e..4b7a18b 100644 --- a/src/be/nikiroo/jvcard/remote/Sync.java +++ b/src/be/nikiroo/jvcard/remote/Sync.java @@ -24,16 +24,17 @@ import be.nikiroo.jvcard.launcher.CardResult; import be.nikiroo.jvcard.launcher.CardResult.MergeCallback; import be.nikiroo.jvcard.parsers.Format; import be.nikiroo.jvcard.parsers.Vcard21Parser; -import be.nikiroo.jvcard.resources.StringUtils; -import be.nikiroo.jvcard.resources.bundles.RemoteBundle; -import be.nikiroo.jvcard.resources.enums.RemotingOption; +import be.nikiroo.jvcard.remote.SimpleSocket.BlockAppendable; +import be.nikiroo.jvcard.resources.RemoteBundle; +import be.nikiroo.jvcard.resources.RemotingOption; +import be.nikiroo.utils.StringUtils; /** * This class will synchronise {@link Card}s between a local instance an a * remote jVCard server. * * @author niki - * + * */ public class Sync { /** The time in ms after which we declare that 2 timestamps are different */ @@ -276,7 +277,9 @@ public class Sync { } case POST_CARD: { s.sendCommand(Command.POST_CARD); - s.sendBlock(Vcard21Parser.toStrings(local)); + BlockAppendable app = s.createBlockAppendable(); + Vcard21Parser.write(app, local); + app.close(); local.saveAs(getCache(cacheDirOrig), Format.VCard21); setLastModified(s.receiveLine()); break; @@ -343,7 +346,9 @@ public class Sync { // ...but without starting with original since it is not // true here s.sendCommand(Command.POST_CARD); - s.sendBlock(Vcard21Parser.toStrings(merge)); + BlockAppendable app = s.createBlockAppendable(); + Vcard21Parser.write(app, merge); + app.close(); String serverLastModifTime = s.receiveLine(); // @@ -409,7 +414,9 @@ public class Sync { } for (Contact c : added) { s.sendCommand(Command.POST_CONTACT, c.getId()); - s.sendBlock(Vcard21Parser.toStrings(c, -1)); + BlockAppendable app = s.createBlockAppendable(); + Vcard21Parser.write(app, c, -1); + s.close(); } if (from.size() > 0) { for (int index = 0; index < from.size(); index++) { @@ -425,7 +432,9 @@ public class Sync { } for (Data d : subadded) { s.sendCommand(Command.POST_DATA, d.getContentState(true)); - s.sendBlock(Vcard21Parser.toStrings(d)); + BlockAppendable app = s.createBlockAppendable(); + Vcard21Parser.write(app, d); + app.close(); } s.sendCommand(Command.PUT_CONTACT); } @@ -514,7 +523,7 @@ public class Sync { * * @param dir * the cache to use - * + * * @return the cached {@link File} */ private File getCache(File dir) {