Export/import realm, fixed bcc import, refactoring

This commit is contained in:
M66B 2019-02-02 19:49:25 +00:00
parent b1235973c2
commit b8947ecd25
2 changed files with 31 additions and 24 deletions

View File

@ -108,24 +108,28 @@ public class EntityAccount implements Serializable {
public JSONObject toJSON() throws JSONException { public JSONObject toJSON() throws JSONException {
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
json.put("name", name); json.put("auth_type", auth_type);
json.put("prefix", prefix);
json.put("host", host); json.put("host", host);
json.put("starttls", starttls); json.put("starttls", starttls);
json.put("insecure", insecure); json.put("insecure", insecure);
json.put("port", port); json.put("port", port);
json.put("user", user); json.put("user", user);
json.put("password", password); json.put("password", password);
json.put("auth_type", auth_type); json.put("realm", password);
json.put("name", name);
json.put("color", color);
json.put("synchronize", synchronize); json.put("synchronize", synchronize);
json.put("primary", primary); json.put("primary", primary);
json.put("notify", notify);
json.put("browse", browse); json.put("browse", browse);
json.put("swipe_left", swipe_left); json.put("swipe_left", swipe_left);
json.put("swipe_right", swipe_right); json.put("swipe_right", swipe_right);
if (color != null)
json.put("color", color);
json.put("notify", notify);
json.put("poll_interval", poll_interval); json.put("poll_interval", poll_interval);
json.put("prefix", prefix);
// not created // not created
// not state // not state
// not error // not error
@ -135,36 +139,37 @@ public class EntityAccount implements Serializable {
public static EntityAccount fromJSON(JSONObject json) throws JSONException { public static EntityAccount fromJSON(JSONObject json) throws JSONException {
EntityAccount account = new EntityAccount(); EntityAccount account = new EntityAccount();
if (json.has("name")) account.auth_type = json.getInt("auth_type");
account.name = json.getString("name");
if (json.has("prefix"))
account.prefix = json.getString("prefix");
account.host = json.getString("host"); account.host = json.getString("host");
account.starttls = (json.has("starttls") && json.getBoolean("starttls")); account.starttls = (json.has("starttls") && json.getBoolean("starttls"));
account.insecure = (json.has("insecure") && json.getBoolean("insecure")); account.insecure = (json.has("insecure") && json.getBoolean("insecure"));
account.port = json.getInt("port"); account.port = json.getInt("port");
account.user = json.getString("user"); account.user = json.getString("user");
account.password = json.getString("password"); account.password = json.getString("password");
account.auth_type = json.getInt("auth_type"); if (json.has("realm"))
account.realm = json.getString("realm");
if (json.has("name"))
account.name = json.getString("name");
if (json.has("color"))
account.color = json.getInt("color");
account.synchronize = json.getBoolean("synchronize"); account.synchronize = json.getBoolean("synchronize");
account.primary = json.getBoolean("primary"); account.primary = json.getBoolean("primary");
if (json.has("notify"))
account.notify = json.getBoolean("notify");
if (json.has("browse")) if (json.has("browse"))
account.browse = json.getBoolean("browse"); account.browse = json.getBoolean("browse");
if (json.has("swipe_left")) if (json.has("swipe_left"))
account.swipe_left = json.getLong("swipe_left"); account.swipe_left = json.getLong("swipe_left");
if (json.has("swipe_right")) if (json.has("swipe_right"))
account.swipe_right = json.getLong("swipe_right"); account.swipe_right = json.getLong("swipe_right");
if (json.has("color"))
account.color = json.getInt("color");
if (json.has("notify"))
account.notify = json.getBoolean("notify");
account.poll_interval = json.getInt("poll_interval"); account.poll_interval = json.getInt("poll_interval");
if (json.has("prefix"))
account.prefix = json.getString("prefix");
return account; return account;
} }

View File

@ -96,6 +96,7 @@ public class EntityIdentity {
json.put("color", color); json.put("color", color);
json.put("signature", signature); json.put("signature", signature);
// not account // not account
json.put("auth_type", auth_type); json.put("auth_type", auth_type);
json.put("host", host); json.put("host", host);
json.put("starttls", starttls); json.put("starttls", starttls);
@ -103,11 +104,14 @@ public class EntityIdentity {
json.put("port", port); json.put("port", port);
json.put("user", user); json.put("user", user);
json.put("password", password); json.put("password", password);
json.put("realm", realm);
json.put("synchronize", synchronize); json.put("synchronize", synchronize);
json.put("primary", primary); json.put("primary", primary);
json.put("replyto", replyto); json.put("replyto", replyto);
json.put("bcc", bcc); json.put("bcc", bcc);
json.put("delivery_receipt", delivery_receipt); json.put("delivery_receipt", delivery_receipt);
json.put("read_receipt", read_receipt); json.put("read_receipt", read_receipt);
json.put("store_sent", store_sent); json.put("store_sent", store_sent);
@ -120,10 +124,8 @@ public class EntityIdentity {
EntityIdentity identity = new EntityIdentity(); EntityIdentity identity = new EntityIdentity();
identity.name = json.getString("name"); identity.name = json.getString("name");
identity.email = json.getString("email"); identity.email = json.getString("email");
if (json.has("display")) if (json.has("display"))
identity.display = json.getString("display"); identity.display = json.getString("display");
if (json.has("color")) if (json.has("color"))
identity.color = json.getInt("color"); identity.color = json.getInt("color");
if (json.has("signature")) if (json.has("signature"))
@ -136,19 +138,19 @@ public class EntityIdentity {
identity.port = json.getInt("port"); identity.port = json.getInt("port");
identity.user = json.getString("user"); identity.user = json.getString("user");
identity.password = json.getString("password"); identity.password = json.getString("password");
if (json.has("realm"))
identity.realm = json.getString("realm");
identity.synchronize = json.getBoolean("synchronize"); identity.synchronize = json.getBoolean("synchronize");
identity.primary = json.getBoolean("primary"); identity.primary = json.getBoolean("primary");
if (json.has("replyto")) if (json.has("replyto"))
identity.replyto = json.getString("replyto"); identity.replyto = json.getString("replyto");
if (json.has("bcc")) if (json.has("bcc"))
identity.replyto = json.getString("bcc"); identity.bcc = json.getString("bcc");
if (json.has("delivery_receipt")) if (json.has("delivery_receipt"))
identity.delivery_receipt = json.getBoolean("delivery_receipt"); identity.delivery_receipt = json.getBoolean("delivery_receipt");
if (json.has("read_receipt")) if (json.has("read_receipt"))
identity.read_receipt = json.getBoolean("read_receipt"); identity.read_receipt = json.getBoolean("read_receipt");