From d1f9bdf9f48eddc9b60f88305814767389533bcb Mon Sep 17 00:00:00 2001 From: Catfriend1 Date: Sun, 16 Jun 2019 18:39:57 +0200 Subject: [PATCH] Config: Add new values for SyncthingNative v1.2.0 (fixes #421) (#424) * model/Options: Add crash*, stun* and unackedNotificationID * ConfigXml: Dismiss unackedNotificationID "crAutoEnabled" * ConfigXml/getOptions: Add unackedNotificationID, crash*, stun* --- .../syncthingandroid/model/Options.java | 14 ++++++++++++++ .../syncthingandroid/util/ConfigXml.java | 18 +++++++++++++----- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/nutomic/syncthingandroid/model/Options.java b/app/src/main/java/com/nutomic/syncthingandroid/model/Options.java index 391fc3d4..404a3944 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/model/Options.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/model/Options.java @@ -47,6 +47,20 @@ public class Options { // Since v1.0.0, see https://github.com/syncthing/syncthing/pull/4888 public int maxConcurrentScans = 1; + // Since v1.2.0 + public String crashReportingURL = "https://crash.syncthing.net/newcrash"; + public boolean crashReportingEnabled = true; + public int stunKeepaliveStartS = 180; + public int stunKeepaliveMinS = 20; + public String stunServer = "default"; + + // Items that may be temporarily missing because they are empty. + /** + * Possible notification IDs: + * crAutoEnabled (crash reporting after upgrade to v1.2.0) + */ + public String unackedNotificationID = ""; + public static class MinHomeDiskFree { public float value = 1; public String unit = "%"; diff --git a/app/src/main/java/com/nutomic/syncthingandroid/util/ConfigXml.java b/app/src/main/java/com/nutomic/syncthingandroid/util/ConfigXml.java index bf02f1c2..88c1e254 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/util/ConfigXml.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/util/ConfigXml.java @@ -309,11 +309,13 @@ public class ConfigXml { for (int i = 0; i < childNodes.getLength(); i++) { Node node = childNodes.item(i); if (node.getNodeName().equals("unackedNotificationID")) { - if (node.equals("fsWatcherNotification")) { - Log.i(TAG, "Remove found unackedNotificationID 'fsWatcherNotification'."); - options.removeChild(node); - changed = true; - break; + switch (getContentOrDefault(node, "")) { + case "crAutoEnabled": + case "fsWatcherNotification": + Log.i(TAG, "Remove found unackedNotificationID '" + node + "'."); + options.removeChild(node); + changed = true; + break; } } } @@ -908,6 +910,12 @@ public class ConfigXml { options.setLowPriority = getContentOrDefault(elementOptions.getElementsByTagName("setLowPriority").item(0), options.setLowPriority); // minHomeDiskFree options.maxConcurrentScans = getContentOrDefault(elementOptions.getElementsByTagName("maxConcurrentScans").item(0), options.maxConcurrentScans); + options.unackedNotificationID = getContentOrDefault(elementOptions.getElementsByTagName("unackedNotificationID").item(0), options.unackedNotificationID); + options.crashReportingURL = getContentOrDefault(elementOptions.getElementsByTagName("crashReportingURL").item(0), options.crashReportingURL); + options.crashReportingEnabled =getContentOrDefault(elementOptions.getElementsByTagName("crashReportingEnabled").item(0), options.crashReportingEnabled); + options.stunKeepaliveStartS = getContentOrDefault(elementOptions.getElementsByTagName("stunKeepaliveStartS").item(0), options.stunKeepaliveStartS); + options.stunKeepaliveMinS = getContentOrDefault(elementOptions.getElementsByTagName("stunKeepaliveMinS").item(0), options.stunKeepaliveMinS); + options.stunServer = getContentOrDefault(elementOptions.getElementsByTagName("stunServer").item(0), options.stunServer); return options; }