diff --git a/src/main/java/org/cryptomator/common/mount/Mounter.java b/src/main/java/org/cryptomator/common/mount/Mounter.java index 459eaa081..8c24c7a69 100644 --- a/src/main/java/org/cryptomator/common/mount/Mounter.java +++ b/src/main/java/org/cryptomator/common/mount/Mounter.java @@ -28,8 +28,8 @@ import static org.cryptomator.integrations.mount.MountCapability.UNMOUNT_FORCED; public class Mounter { private static final List problematicFuseMountServices = List.of("org.cryptomator.frontend.fuse.mount.MacFuseMountProvider", "org.cryptomator.frontend.fuse.mount.FuseTMountProvider"); - private final Environment env; + private final Settings settings; private final WindowsDriveLetters driveLetters; private final List mountProviders; private final AtomicReference firstUsedProblematicFuseMountService; @@ -37,11 +37,12 @@ public class Mounter { @Inject public Mounter(Environment env, // + Settings settings, // WindowsDriveLetters driveLetters, // List mountProviders, // - @Named("FUPFMS") AtomicReference firstUsedProblematicFuseMountService, - ObservableValue defaultMountService) { + @Named("FUPFMS") AtomicReference firstUsedProblematicFuseMountService, ObservableValue defaultMountService) { this.env = env; + this.settings = settings; this.driveLetters = driveLetters; this.mountProviders = mountProviders; this.firstUsedProblematicFuseMountService = firstUsedProblematicFuseMountService; @@ -64,7 +65,13 @@ public class Mounter { for (var capability : service.capabilities()) { switch (capability) { case FILE_SYSTEM_NAME -> builder.setFileSystemName("cryptoFs"); - case LOOPBACK_PORT -> builder.setLoopbackPort(vaultSettings.port.get()); + case LOOPBACK_PORT -> { + if (vaultSettings.mountService.getValue() == null) { + builder.setLoopbackPort(settings.port.get()); + } else { + builder.setLoopbackPort(vaultSettings.port.get()); + } + } case LOOPBACK_HOST_NAME -> env.getLoopbackAlias().ifPresent(builder::setLoopbackHostName); case READ_ONLY -> builder.setReadOnly(vaultSettings.usesReadOnlyMode.get()); case MOUNT_FLAGS -> { @@ -146,8 +153,7 @@ public class Mounter { var targetIsProblematicFuse = isProblematicFuseService(selMntServ); if (targetIsProblematicFuse && firstUsedProblematicFuseMountService.get() == null) { firstUsedProblematicFuseMountService.set(selMntServ); - } - else if (targetIsProblematicFuse && !firstUsedProblematicFuseMountService.get().equals(selMntServ)) { + } else if (targetIsProblematicFuse && !firstUsedProblematicFuseMountService.get().equals(selMntServ)) { throw new FuseRestartRequiredException("Failed to mount the specified mount service."); } diff --git a/src/main/java/org/cryptomator/ui/preferences/VolumePreferencesController.java b/src/main/java/org/cryptomator/ui/preferences/VolumePreferencesController.java index c02a59ee5..7250fac49 100644 --- a/src/main/java/org/cryptomator/ui/preferences/VolumePreferencesController.java +++ b/src/main/java/org/cryptomator/ui/preferences/VolumePreferencesController.java @@ -23,9 +23,9 @@ import java.util.ResourceBundle; @PreferencesScoped public class VolumePreferencesController implements FxController { - private static final String DOCS_MOUNTING_URL = "https://docs.cryptomator.org/en/1.7/desktop/volume-type/"; - private static final int MIN_PORT = 1024; - private static final int MAX_PORT = 65535; + public static final String DOCS_MOUNTING_URL = "https://docs.cryptomator.org/en/1.7/desktop/volume-type/"; + public static final int MIN_PORT = 1024; + public static final int MAX_PORT = 65535; private final Settings settings; private final ObservableValue selectedMountService; @@ -42,9 +42,9 @@ public class VolumePreferencesController implements FxController { public Button loopbackPortApplyButton; @Inject - VolumePreferencesController(Settings settings, - Lazy application, - List mountProviders, + VolumePreferencesController(Settings settings, // + Lazy application, // + List mountProviders, // ResourceBundle resourceBundle) { this.settings = settings; this.application = application; @@ -101,6 +101,7 @@ public class VolumePreferencesController implements FxController { public boolean isLoopbackPortSupported() { return loopbackPortSupported.get(); } + public ObservableValue readonlySupportedProperty() { return readonlySupported; } diff --git a/src/main/java/org/cryptomator/ui/vaultoptions/MountOptionsController.java b/src/main/java/org/cryptomator/ui/vaultoptions/MountOptionsController.java index edcf0bb23..4d8264a71 100644 --- a/src/main/java/org/cryptomator/ui/vaultoptions/MountOptionsController.java +++ b/src/main/java/org/cryptomator/ui/vaultoptions/MountOptionsController.java @@ -4,12 +4,14 @@ import com.google.common.base.Strings; import dagger.Lazy; import org.cryptomator.common.mount.Mounter; import org.cryptomator.common.mount.WindowsDriveLetters; -import org.cryptomator.common.settings.Settings; import org.cryptomator.common.settings.VaultSettings; import org.cryptomator.common.vaults.Vault; import org.cryptomator.integrations.mount.MountCapability; import org.cryptomator.integrations.mount.MountService; import org.cryptomator.ui.common.FxController; +import org.cryptomator.ui.fxapp.FxApplicationWindows; +import org.cryptomator.ui.preferences.SelectedPreferencesTab; +import org.cryptomator.ui.preferences.VolumePreferencesController; import javax.inject.Inject; import javax.inject.Named; @@ -41,10 +43,6 @@ import java.util.concurrent.atomic.AtomicReference; @VaultOptionsScoped public class MountOptionsController implements FxController { - private static final String DOCS_MOUNTING_URL = "https://docs.cryptomator.org/en/1.7/desktop/volume-type/"; - private static final int MIN_PORT = 1024; - private static final int MAX_PORT = 65535; - private final Stage window; private final VaultSettings vaultSettings; private final WindowsDriveLetters windowsDriveLetters; @@ -56,7 +54,9 @@ public class MountOptionsController implements FxController { private final ObservableValue mountpointDriveLetterSupported; private final ObservableValue readOnlySupported; private final ObservableValue mountFlagsSupported; + private final ObservableValue defaultMountServiceSelected; private final ObservableValue directoryPath; + private final FxApplicationWindows applicationWindows; private final List mountProviders; private final ObservableValue defaultMountService; private final ObservableValue selectedMountService; @@ -81,17 +81,19 @@ public class MountOptionsController implements FxController { @Inject MountOptionsController(@VaultOptionsWindow Stage window, // - Settings settings, // @VaultOptionsWindow Vault vault, // WindowsDriveLetters windowsDriveLetters, // ResourceBundle resourceBundle, // + FxApplicationWindows applicationWindows, // Lazy application, // List mountProviders, // - @Named("FUPFMS") AtomicReference firstUsedProblematicFuseMountService, ObservableValue defaultMountService) { + @Named("FUPFMS") AtomicReference firstUsedProblematicFuseMountService, // + ObservableValue defaultMountService) { this.window = window; this.vaultSettings = vault.getVaultSettings(); this.windowsDriveLetters = windowsDriveLetters; this.resourceBundle = resourceBundle; + this.applicationWindows = applicationWindows; this.directoryPath = vault.getVaultSettings().mountPoint.map(p -> isDriveLetter(p) ? null : p.toString()); this.application = application; this.mountProviders = mountProviders; @@ -102,7 +104,7 @@ public class MountOptionsController implements FxController { && Mounter.isProblematicFuseService(s) // && !firstUsedProblematicFuseMountService.get().equals(s); }); - this.loopbackPortSupported = BooleanExpression.booleanExpression(selectedMountService.map(s -> s.hasCapability(MountCapability.LOOPBACK_PORT))); + this.loopbackPortSupported = BooleanExpression.booleanExpression(selectedMountService.map(s -> s.hasCapability(MountCapability.LOOPBACK_PORT) && vaultSettings.mountService.getValue() != null)); this.defaultMountFlags = selectedMountService.map(s -> { if (s.hasCapability(MountCapability.MOUNT_FLAGS)) { @@ -112,6 +114,7 @@ public class MountOptionsController implements FxController { } }); this.mountFlagsSupported = selectedMountService.map(s -> s.hasCapability(MountCapability.MOUNT_FLAGS)); + this.defaultMountServiceSelected = selectedMountService.map(_ -> vaultSettings.mountService.getValue() == null); this.readOnlySupported = selectedMountService.map(s -> s.hasCapability(MountCapability.READ_ONLY)); this.mountpointDirSupported = selectedMountService.map(s -> s.hasCapability(MountCapability.MOUNT_TO_EXISTING_DIR) || s.hasCapability(MountCapability.MOUNT_WITHIN_EXISTING_PARENT)); this.mountpointDriveLetterSupported = selectedMountService.map(s -> s.hasCapability(MountCapability.MOUNT_AS_DRIVE_LETTER)); @@ -170,6 +173,11 @@ public class MountOptionsController implements FxController { } + @FXML + public void openVolumePreferences() { + applicationWindows.showPreferencesWindow(SelectedPreferencesTab.VOLUME); + } + @FXML public void toggleUseCustomMountFlags() { if (customMountFlagsCheckbox.isSelected()) { @@ -287,14 +295,14 @@ public class MountOptionsController implements FxController { } public void openDocs() { - application.get().getHostServices().showDocument(DOCS_MOUNTING_URL); + application.get().getHostServices().showDocument(VolumePreferencesController.DOCS_MOUNTING_URL); } private boolean validateLoopbackPort() { try { int port = Integer.parseInt(vaultLoopbackPortField.getText()); return port == 0 // choose port automatically - || port >= MIN_PORT && port <= MAX_PORT; // port within range + || port >= VolumePreferencesController.MIN_PORT && port <= VolumePreferencesController.MAX_PORT; // port within range } catch (NumberFormatException e) { return false; } @@ -320,6 +328,14 @@ public class MountOptionsController implements FxController { return mountFlagsSupported.getValue(); } + public ObservableValue defaultMountServiceSelectedProperty() { + return defaultMountServiceSelected; + } + + public boolean isDefaultMountServiceSelected() { + return defaultMountServiceSelected.getValue(); + } + public ObservableValue mountpointDirSupportedProperty() { return mountpointDirSupported; } diff --git a/src/main/resources/fxml/vault_options_mount.fxml b/src/main/resources/fxml/vault_options_mount.fxml index d11cd105e..031e1be1d 100644 --- a/src/main/resources/fxml/vault_options_mount.fxml +++ b/src/main/resources/fxml/vault_options_mount.fxml @@ -14,6 +14,7 @@ + + + +