mirror of
https://github.com/syncthing/syncthing-android.git
synced 2025-01-08 11:11:34 +00:00
Update model/Gui to syncthing v1.0.1 (#334)
* Update model/Gui * Add ConfigXml#getGui
This commit is contained in:
parent
e9dbda73e7
commit
06526c5547
2 changed files with 47 additions and 8 deletions
|
@ -1,14 +1,30 @@
|
||||||
package com.nutomic.syncthingandroid.model;
|
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 class Gui {
|
||||||
public boolean enabled;
|
public boolean debugging = false;
|
||||||
public String address;
|
public boolean enabled = true;
|
||||||
public String user;
|
|
||||||
public String password;
|
/**
|
||||||
public boolean useTLS;
|
* REST: useTLS
|
||||||
public String apiKey;
|
* XML: tls
|
||||||
public boolean insecureAdminAccess;
|
*/
|
||||||
public String theme;
|
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() {
|
public String getBindAddress() {
|
||||||
if (address == null) {
|
if (address == null) {
|
||||||
|
|
|
@ -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() {
|
public Options getOptions() {
|
||||||
Options defaultOptions = new Options();
|
Options defaultOptions = new Options();
|
||||||
Element elementOptions = (Element) mConfig.getDocumentElement().getElementsByTagName("options").item(0);
|
Element elementOptions = (Element) mConfig.getDocumentElement().getElementsByTagName("options").item(0);
|
||||||
|
|
Loading…
Reference in a new issue