mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-09-20 06:54:16 +00:00
implemented NetworkSettingsJson
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
package org.cryptomator.common.settings;
|
||||
|
||||
import javafx.beans.Observable;
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
import javafx.beans.property.IntegerProperty;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javafx.beans.property.SimpleIntegerProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
|
||||
public class NetworkSettings {
|
||||
|
||||
public final ObjectProperty<ProxyMode> mode;
|
||||
public final StringProperty httpProxy;
|
||||
public final IntegerProperty httpPort;
|
||||
public final BooleanProperty samePortProxyForHttpHttps;
|
||||
public final StringProperty httpsProxy;
|
||||
public final IntegerProperty httpsPort;
|
||||
|
||||
NetworkSettings(NetworkSettingsJson json){
|
||||
this.mode = new SimpleObjectProperty<>(this, "mode", json.mode);
|
||||
this.httpProxy = new SimpleStringProperty(this, "httpProxy", json.httpProxy);
|
||||
this.httpPort = new SimpleIntegerProperty(this, "httpPort", json.httpPort);
|
||||
this.samePortProxyForHttpHttps = new SimpleBooleanProperty(this, "samePortProxyForHttpHttps", json.samePortProxyForHttpHttps);
|
||||
this.httpsProxy = new SimpleStringProperty(this, "httpsProxy", json.httpsProxy);
|
||||
this.httpsPort = new SimpleIntegerProperty(this, "httpsPort", json.httpsPort);
|
||||
}
|
||||
|
||||
NetworkSettingsJson serialized(){
|
||||
var json = new NetworkSettingsJson();
|
||||
json.mode = mode.get();
|
||||
json.httpProxy = httpProxy.get();
|
||||
json.httpPort = httpPort.get();
|
||||
json.samePortProxyForHttpHttps = samePortProxyForHttpHttps.get();
|
||||
json.httpsProxy = httpsProxy.get();
|
||||
json.httpsPort = httpsPort.get();
|
||||
return json;
|
||||
}
|
||||
|
||||
Observable[] observables() {
|
||||
return new Observable[]{mode, httpProxy, httpPort,httpsProxy,httpsPort};
|
||||
}
|
||||
|
||||
public enum ProxyMode {
|
||||
NO,
|
||||
SYSTEM,
|
||||
MANUAL
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.cryptomator.common.settings;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
class NetworkSettingsJson {
|
||||
|
||||
@JsonProperty("mode")
|
||||
NetworkSettings.ProxyMode mode = NetworkSettings.ProxyMode.NO;
|
||||
|
||||
@JsonProperty("httpProxy")
|
||||
String httpProxy;
|
||||
|
||||
@JsonProperty("httpPort")
|
||||
int httpPort;
|
||||
|
||||
@JsonProperty("samePortProxyForHttpHttps")
|
||||
boolean samePortProxyForHttpHttps;
|
||||
|
||||
@JsonProperty(value = "httpsProxy")
|
||||
String httpsProxy;
|
||||
|
||||
@JsonProperty("httpsPort")
|
||||
int httpsPort;
|
||||
|
||||
}
|
||||
@@ -47,6 +47,7 @@ public class Settings {
|
||||
static final boolean DEFAULT_SHOW_MINIMIZE_BUTTON = false;
|
||||
public static final Instant DEFAULT_TIMESTAMP = Instant.parse("2000-01-01T00:00:00Z");
|
||||
public final ObservableList<VaultSettings> directories;
|
||||
public final ObjectProperty<NetworkSettings> networkSettings;
|
||||
public final BooleanProperty askedForUpdateCheck;
|
||||
public final BooleanProperty checkForUpdates;
|
||||
public final BooleanProperty startHidden;
|
||||
@@ -84,6 +85,7 @@ public class Settings {
|
||||
*/
|
||||
Settings(SettingsJson json) {
|
||||
this.directories = FXCollections.observableArrayList(VaultSettings::observables);
|
||||
this.networkSettings = new SimpleObjectProperty<>(this, "networkSettings", new NetworkSettings(json.networkSettings));
|
||||
this.askedForUpdateCheck = new SimpleBooleanProperty(this, "askedForUpdateCheck", json.askedForUpdateCheck);
|
||||
this.checkForUpdates = new SimpleBooleanProperty(this, "checkForUpdates", json.checkForUpdatesEnabled);
|
||||
this.startHidden = new SimpleBooleanProperty(this, "startHidden", json.startHidden);
|
||||
@@ -111,6 +113,7 @@ public class Settings {
|
||||
migrateLegacySettings(json);
|
||||
|
||||
directories.addListener(this::somethingChanged);
|
||||
networkSettings.addListener(this::somethingChanged);
|
||||
askedForUpdateCheck.addListener(this::somethingChanged);
|
||||
checkForUpdates.addListener(this::somethingChanged);
|
||||
startHidden.addListener(this::somethingChanged);
|
||||
@@ -165,6 +168,7 @@ public class Settings {
|
||||
SettingsJson serialized() {
|
||||
var json = new SettingsJson();
|
||||
json.directories = directories.stream().map(VaultSettings::serialized).toList();
|
||||
json.networkSettings = networkSettings.get().serialized();
|
||||
json.askedForUpdateCheck = askedForUpdateCheck.get();
|
||||
json.checkForUpdatesEnabled = checkForUpdates.get();
|
||||
json.startHidden = startHidden.get();
|
||||
|
||||
@@ -15,6 +15,9 @@ class SettingsJson {
|
||||
@JsonProperty("directories")
|
||||
List<VaultSettingsJson> directories = List.of();
|
||||
|
||||
@JsonProperty("networkSettings")
|
||||
NetworkSettingsJson networkSettings = new NetworkSettingsJson();
|
||||
|
||||
@JsonProperty("writtenByVersion")
|
||||
String writtenByVersion;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user