Pārlūkot izejas kodu

remove port from settings

Jan-Peter Klein 1 gadu atpakaļ
vecāks
revīzija
49769f986a

+ 4 - 3
src/main/java/org/cryptomator/common/CommonsModule.java

@@ -12,6 +12,7 @@ import org.cryptomator.common.keychain.KeychainModule;
 import org.cryptomator.common.mount.MountModule;
 import org.cryptomator.common.settings.Settings;
 import org.cryptomator.common.settings.SettingsProvider;
+import org.cryptomator.common.settings.VaultSettings;
 import org.cryptomator.common.vaults.VaultComponent;
 import org.cryptomator.common.vaults.VaultListModule;
 import org.cryptomator.cryptolib.common.MasterkeyFileAccess;
@@ -139,10 +140,10 @@ public abstract class CommonsModule {
 
 	@Provides
 	@Singleton
-	static ObservableValue<InetSocketAddress> provideServerSocketAddressBinding(Settings settings) {
-		return settings.port.map(port -> {
+	static ObservableValue<InetSocketAddress> provideServerSocketAddressBinding(VaultSettings vaultSettings) {
+		return vaultSettings.port.map(port -> {
 			String host = SystemUtils.IS_OS_WINDOWS ? "127.0.0.1" : "localhost";
-			return InetSocketAddress.createUnresolved(host, settings.port.intValue());
+			return InetSocketAddress.createUnresolved(host, vaultSettings.port.intValue());
 		});
 	}
 

+ 0 - 5
src/main/java/org/cryptomator/common/settings/Settings.java

@@ -36,7 +36,6 @@ public class Settings {
 	static final boolean DEFAULT_START_HIDDEN = false;
 	static final boolean DEFAULT_AUTO_CLOSE_VAULTS = false;
 	static final boolean DEFAULT_USE_KEYCHAIN = true;
-	static final int DEFAULT_PORT = 42427;
 	static final int DEFAULT_NUM_TRAY_NOTIFICATIONS = 3;
 	static final boolean DEFAULT_DEBUG_MODE = false;
 	static final UiTheme DEFAULT_THEME = UiTheme.LIGHT;
@@ -52,7 +51,6 @@ public class Settings {
 	public final BooleanProperty startHidden;
 	public final BooleanProperty autoCloseVaults;
 	public final BooleanProperty useKeychain;
-	public final IntegerProperty port;
 	public final IntegerProperty numTrayNotifications;
 	public final BooleanProperty debugMode;
 	public final ObjectProperty<UiTheme> theme;
@@ -89,7 +87,6 @@ public class Settings {
 		this.startHidden = new SimpleBooleanProperty(this, "startHidden", json.startHidden);
 		this.autoCloseVaults = new SimpleBooleanProperty(this, "autoCloseVaults", json.autoCloseVaults);
 		this.useKeychain = new SimpleBooleanProperty(this, "useKeychain", json.useKeychain);
-		this.port = new SimpleIntegerProperty(this, "webDavPort", json.port);
 		this.numTrayNotifications = new SimpleIntegerProperty(this, "numTrayNotifications", json.numTrayNotifications);
 		this.debugMode = new SimpleBooleanProperty(this, "debugMode", json.debugMode);
 		this.theme = new SimpleObjectProperty<>(this, "theme", json.theme);
@@ -116,7 +113,6 @@ public class Settings {
 		startHidden.addListener(this::somethingChanged);
 		autoCloseVaults.addListener(this::somethingChanged);
 		useKeychain.addListener(this::somethingChanged);
-		port.addListener(this::somethingChanged);
 		numTrayNotifications.addListener(this::somethingChanged);
 		debugMode.addListener(this::somethingChanged);
 		theme.addListener(this::somethingChanged);
@@ -170,7 +166,6 @@ public class Settings {
 		json.startHidden = startHidden.get();
 		json.autoCloseVaults = autoCloseVaults.get();
 		json.useKeychain = useKeychain.get();
-		json.port = port.get();
 		json.numTrayNotifications = numTrayNotifications.get();
 		json.debugMode = debugMode.get();
 		json.theme = theme.get();

+ 0 - 3
src/main/java/org/cryptomator/common/settings/SettingsJson.java

@@ -46,9 +46,6 @@ class SettingsJson {
 	@JsonProperty("numTrayNotifications")
 	int numTrayNotifications = Settings.DEFAULT_NUM_TRAY_NOTIFICATIONS;
 
-	@JsonProperty("port")
-	int port = Settings.DEFAULT_PORT;
-
 	@JsonProperty("showMinimizeButton")
 	boolean showMinimizeButton = Settings.DEFAULT_SHOW_MINIMIZE_BUTTON;
 

+ 1 - 0
src/main/java/org/cryptomator/common/settings/VaultSettings.java

@@ -38,6 +38,7 @@ public class VaultSettings {
 	static final WhenUnlocked DEFAULT_ACTION_AFTER_UNLOCK = WhenUnlocked.ASK;
 	static final boolean DEFAULT_AUTOLOCK_WHEN_IDLE = false;
 	static final int DEFAULT_AUTOLOCK_IDLE_SECONDS = 30 * 60;
+	static final int DEFAULT_PORT = 42427;
 
 	private static final Random RNG = new Random();
 

+ 1 - 1
src/main/java/org/cryptomator/common/settings/VaultSettingsJson.java

@@ -49,7 +49,7 @@ class VaultSettingsJson {
 	String mountService;
 
 	@JsonProperty("port")
-	int port = Settings.DEFAULT_PORT;
+	int port = VaultSettings.DEFAULT_PORT;
 
 	@Deprecated(since = "1.7.0")
 	@JsonProperty(value = "winDriveLetter", access = JsonProperty.Access.WRITE_ONLY) // WRITE_ONLY means value is "written" into the java object during deserialization. Upvote this: https://github.com/FasterXML/jackson-annotations/issues/233

+ 2 - 2
src/main/java/org/cryptomator/common/vaults/VaultListManager.java

@@ -73,8 +73,8 @@ public class VaultListManager {
 	private VaultSettings newVaultSettings(Path path) {
 		VaultSettings vaultSettings = VaultSettings.withRandomId();
 		vaultSettings.path.set(path);
-		vaultSettings.mountService.set(settings.mountService.getValue());
-		vaultSettings.port.set(settings.port.getValue());
+		vaultSettings.mountService.set(vaultSettings.mountService.getValue());
+		vaultSettings.port.set(vaultSettings.port.getValue());
 		if (path.getFileName() != null) {
 			vaultSettings.displayName.set(path.getFileName().toString());
 		} else {

+ 0 - 2
src/test/java/org/cryptomator/common/settings/SettingsJsonTest.java

@@ -26,7 +26,6 @@ public class SettingsJsonTest {
 					],
 					"autoCloseVaults" : true,
 					"checkForUpdatesEnabled": true,
-					"port": 8080,
 					"language": "de-DE",
 					"numTrayNotifications": 42
 				}
@@ -39,7 +38,6 @@ public class SettingsJsonTest {
 		Assertions.assertEquals("/vault1", jsonObj.directories.get(0).path);
 		Assertions.assertEquals("/vault2", jsonObj.directories.get(1).path);
 		Assertions.assertEquals("--foo --bar", jsonObj.directories.get(1).mountFlags);
-		Assertions.assertEquals(8080, jsonObj.port);
 		Assertions.assertTrue(jsonObj.autoCloseVaults);
 		Assertions.assertEquals("de-DE", jsonObj.language);
 		Assertions.assertEquals(42, jsonObj.numTrayNotifications);

+ 2 - 6
src/test/java/org/cryptomator/common/settings/SettingsTest.java

@@ -24,16 +24,12 @@ public class SettingsTest {
 		Mockito.verify(changeListener, Mockito.times(0)).accept(settings);
 
 		// first change (to property):
-		settings.port.set(42428);
+		settings.directories.add(vaultSettings);
 		Mockito.verify(changeListener, Mockito.times(1)).accept(settings);
 
 		// second change (to list):
-		settings.directories.add(vaultSettings);
-		Mockito.verify(changeListener, Mockito.times(2)).accept(settings);
-
-		// third change (to property of list item):
 		vaultSettings.displayName.set("asd");
-		Mockito.verify(changeListener, Mockito.times(3)).accept(settings);
+		Mockito.verify(changeListener, Mockito.times(2)).accept(settings);
 	}
 
 }