import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
import be.nikiroo.jvcard.Card;
import be.nikiroo.jvcard.Contact;
import be.nikiroo.jvcard.launcher.CardResult.MergeCallback;
import be.nikiroo.jvcard.parsers.Format;
import be.nikiroo.jvcard.parsers.Vcard21Parser;
-import be.nikiroo.jvcard.resources.Bundles;
+import be.nikiroo.jvcard.remote.SimpleSocket.BlockAppendable;
import be.nikiroo.jvcard.resources.StringUtils;
+import be.nikiroo.jvcard.resources.bundles.RemoteBundle;
+import be.nikiroo.jvcard.resources.enums.RemotingOption;
/**
* This class will synchronise {@link Card}s between a local instance an a
}
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;
// ...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();
//
}
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++) {
}
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);
}
*/
static private void config() {
String dir = null;
- ResourceBundle bundle = Bundles.getBundle("remote");
+ RemoteBundle bundle = new RemoteBundle();
try {
- dir = bundle.getString("CLIENT_CACHE_DIR").trim();
+ dir = bundle.getString(RemotingOption.CLIENT_CACHE_DIR);
cacheDir = new File(dir + File.separator + "current");
cacheDir.mkdir();
+ dir);
}
- String autoStr = bundle.getString("CLIENT_AUTO_SYNC");
- if (autoStr != null && autoStr.trim().equalsIgnoreCase("true")) {
- autoSync = true;
- }
-
- } catch (MissingResourceException e) {
- throw new InvalidParameterException(
- "Cannot access remote.properties configuration file");
+ autoSync = bundle
+ .getBoolean(RemotingOption.CLIENT_AUTO_SYNC, false);
} catch (Exception e) {
throw new InvalidParameterException(
"Cannot open or create cache store at: " + dir);