1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2025-01-07 10:42:07 +00:00

Update model/Gui to syncthing v1.0.1 (#334)

* Update model/Gui

* Add ConfigXml#getGui
This commit is contained in:
Catfriend1 2019-02-24 11:53:05 +01:00 committed by GitHub
parent e9dbda73e7
commit 06526c5547
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 47 additions and 8 deletions

View file

@ -1,14 +1,30 @@
package com.nutomic.syncthingandroid.model;
/**
* Sources:
* - https://github.com/syncthing/syncthing/tree/master/lib/config
* - https://github.com/syncthing/syncthing/blob/master/lib/config/guiconfiguration.go
*/
public class Gui {
public boolean enabled;
public String address;
public String user;
public String password;
public boolean useTLS;
public String apiKey;
public boolean insecureAdminAccess;
public String theme;
public boolean debugging = false;
public boolean enabled = true;
/**
* REST: useTLS
* XML: tls
*/
public boolean useTLS = false;
public String address = "127.0.0.1:8384";
public String user = "syncthing"; // Default in this app
public String password; // This will be set to the "apiKey" in {@link ConfigXml#}
public String apiKey; // Automatically generated by SyncthingNative
public String theme = "default";
// omitEmpty
public boolean insecureAdminAccess = false;
public boolean insecureAllowFrameLoading = false;
public boolean insecureSkipHostCheck = false;
public String getBindAddress() {
if (address == null) {

View file

@ -817,6 +817,29 @@ public class ConfigXml {
}
}
public Gui getGui() {
Gui defaultGui = new Gui();
Element elementGui = (Element) mConfig.getDocumentElement().getElementsByTagName("gui").item(0);
if (elementGui == null) {
Log.e(TAG, "getGui: elementGui == null. Returning defaults.");
return defaultGui;
}
Gui gui = new Gui();
gui.debugging = getAttributeOrDefault(elementGui, "debugging", defaultGui.debugging);
gui.enabled = getAttributeOrDefault(elementGui, "enabled", defaultGui.enabled);
gui.useTLS = getAttributeOrDefault(elementGui, "tls", defaultGui.useTLS);
gui.address = getContentOrDefault(elementGui.getElementsByTagName("address").item(0), defaultGui.address);
gui.user = getContentOrDefault(elementGui.getElementsByTagName("user").item(0), defaultGui.user);
gui.password = getContentOrDefault(elementGui.getElementsByTagName("password").item(0), "");
gui.apiKey = getContentOrDefault(elementGui.getElementsByTagName("apiKey").item(0), "");
gui.theme = getContentOrDefault(elementGui.getElementsByTagName("theme").item(0), defaultGui.theme);
gui.insecureAdminAccess = getContentOrDefault(elementGui.getElementsByTagName("insecureAdminAccess").item(0), defaultGui.insecureAdminAccess);
gui.insecureAllowFrameLoading = getContentOrDefault(elementGui.getElementsByTagName("insecureAllowFrameLoading").item(0), defaultGui.insecureAllowFrameLoading);
gui.insecureSkipHostCheck = getContentOrDefault(elementGui.getElementsByTagName("insecureSkipHostCheck").item(0), defaultGui.insecureSkipHostCheck);
return gui;
}
public Options getOptions() {
Options defaultOptions = new Options();
Element elementOptions = (Element) mConfig.getDocumentElement().getElementsByTagName("options").item(0);