瀏覽代碼

renaming NioAdapter-Interface to Volume to prevent confusing to FUSE-project

infeo 7 年之前
父節點
當前提交
242b1e92a3

+ 1 - 1
main/pom.xml

@@ -28,7 +28,7 @@
 		<cryptomator.cryptofs.version>1.4.5</cryptomator.cryptofs.version>
 		<cryptomator.webdav.version>1.0.3</cryptomator.webdav.version>
 		<cryptomator.jni.version>1.0.2</cryptomator.jni.version>
-		<cryptomator.fuse.version>0.1.1-SNAPSHOT</cryptomator.fuse.version>
+		<cryptomator.fuse.version>0.1.2-SNAPSHOT</cryptomator.fuse.version>
 
 		<commons-io.version>2.5</commons-io.version>
 		<commons-lang3.version>3.6</commons-lang3.version>

+ 12 - 12
main/ui/src/main/java/org/cryptomator/ui/controllers/SettingsController.java

@@ -56,10 +56,10 @@ public class SettingsController implements ViewController {
 	private CheckBox checkForUpdatesCheckbox;
 
 	@FXML
-	private GridPane webdavNioAdapter;
+	private GridPane webdavVolume;
 
 	@FXML
-	private GridPane fuseNioAdapter;
+	private GridPane fuseVolume;
 
 	@FXML
 	private Label portFieldLabel;
@@ -80,7 +80,7 @@ public class SettingsController implements ViewController {
 	private ChoiceBox<String> prefGvfsScheme;
 
 	@FXML
-	private Label nioAdapterLabel;
+	private Label volumeLabel;
 
 	@FXML
 	private ChoiceBox<String> nioAdapter;
@@ -105,12 +105,12 @@ public class SettingsController implements ViewController {
 
 
 		//WEBDAV
-		webdavNioAdapter.managedProperty().bind(webdavNioAdapter.visibleProperty());
-		prefGvfsScheme.managedProperty().bind(webdavNioAdapter.visibleProperty());
-		prefGvfsSchemeLabel.managedProperty().bind(webdavNioAdapter.visibleProperty());
-		portFieldLabel.managedProperty().bind(webdavNioAdapter.visibleProperty());
-		changePortButton.managedProperty().bind(webdavNioAdapter.visibleProperty());
-		portField.managedProperty().bind(webdavNioAdapter.visibleProperty());
+		webdavVolume.managedProperty().bind(webdavVolume.visibleProperty());
+		prefGvfsScheme.managedProperty().bind(webdavVolume.visibleProperty());
+		prefGvfsSchemeLabel.managedProperty().bind(webdavVolume.visibleProperty());
+		portFieldLabel.managedProperty().bind(webdavVolume.visibleProperty());
+		changePortButton.managedProperty().bind(webdavVolume.visibleProperty());
+		portField.managedProperty().bind(webdavVolume.visibleProperty());
 		portField.setText(String.valueOf(settings.port().intValue()));
 		portField.addEventFilter(KeyEvent.KEY_TYPED, this::filterNumericKeyEvents);
 		changePortButton.visibleProperty().bind(settings.port().asString().isNotEqualTo(portField.textProperty()));
@@ -122,7 +122,7 @@ public class SettingsController implements ViewController {
 		prefGvfsScheme.setVisible(SystemUtils.IS_OS_LINUX);
 
 		//FUSE
-		fuseNioAdapter.managedProperty().bind(fuseNioAdapter.visibleProperty());
+		fuseVolume.managedProperty().bind(fuseVolume.visibleProperty());
 
 		debugModeCheckbox.setSelected(settings.debugMode().get());
 
@@ -138,8 +138,8 @@ public class SettingsController implements ViewController {
 	}
 
 	private void changeNioView(String newVal) {
-		fuseNioAdapter.setVisible(newVal.equalsIgnoreCase(NioAdapterImpl.FUSE.name()));
-		webdavNioAdapter.setVisible(newVal.equalsIgnoreCase(NioAdapterImpl.WEBDAV.name()));
+		fuseVolume.setVisible(newVal.equalsIgnoreCase(NioAdapterImpl.FUSE.name()));
+		webdavVolume.setVisible(newVal.equalsIgnoreCase(NioAdapterImpl.WEBDAV.name()));
 	}
 
 	@Override

+ 26 - 11
main/ui/src/main/java/org/cryptomator/ui/model/FuseNioAdapter.java

@@ -14,9 +14,11 @@ import javax.inject.Inject;
 import java.nio.file.Paths;
 
 @VaultModule.PerVault
-public class FuseNioAdapter implements NioAdapter {
+public class FuseVolume implements Volume {
 
-	private static final Logger LOG = LoggerFactory.getLogger(FuseNioAdapter.class);
+	private static final Logger LOG = LoggerFactory.getLogger(FuseVolume.class);
+	private static final String DEFAULT_MOUNTROOTPATH_MAC = System.getProperty("user.home") + "Library/Application Support/Cryptomator";
+	private static final String DEFAULT_MOUNTROOTPATH_LINUX = System.getProperty("user.home") + ".Cryptomator";
 
 	private final FuseMount fuseMnt;
 	private final VaultSettings vaultSettings;
@@ -25,7 +27,7 @@ public class FuseNioAdapter implements NioAdapter {
 	private CryptoFileSystem cfs;
 
 	@Inject
-	public FuseNioAdapter(VaultSettings vaultSettings, WindowsDriveLetters windowsDriveLetters) {
+	public FuseVolume(VaultSettings vaultSettings, WindowsDriveLetters windowsDriveLetters) {
 		this.vaultSettings = vaultSettings;
 		this.windowsDriveLetters = windowsDriveLetters;
 		this.fuseMnt = MountFactory.createMountObject();
@@ -44,8 +46,7 @@ public class FuseNioAdapter implements NioAdapter {
 		try {
 			EnvironmentVariables envVars = EnvironmentVariables.create()
 					.withMountName(vaultSettings.mountName().getValue() + vaultSettings.getId())
-					.withMountPath(
-							SystemUtils.IS_OS_WINDOWS? computeWinDriveLetter() : vaultSettings.mountPath().getValue())
+					.withMountPath(chooseMountRootPath())
 					.build();
 			fuseMnt.mount(cfs.getPath("/"), envVars);
 		} catch (Exception e) {
@@ -53,13 +54,27 @@ public class FuseNioAdapter implements NioAdapter {
 		}
 	}
 
-	private String computeWinDriveLetter(){
-		if(vaultSettings.winDriveLetter().get() != null){
-			return vaultSettings.winDriveLetter().getValue()+":\\";
-		}
-		else{
-			return windowsDriveLetters.getAvailableDriveLetters().iterator().next()+":\\";
+	private String chooseMountRootPath() {
+		if (SystemUtils.IS_OS_WINDOWS) {
+			//windows case
+			if (vaultSettings.winDriveLetter().get() != null) {
+				// specific drive letter selected
+				return vaultSettings.winDriveLetter().getValue() + ":\\";
+			} else {
+				// auto assign drive letter selected
+				return windowsDriveLetters.getAvailableDriveLetters().iterator().next() + ":\\";
+			}
+		} else {
+			if (vaultSettings.mountPath().isNotNull().get()) {
+				//specific path given
+				vaultSettings.mountPath().getValue();
+			} else {
+				//choose default path
+				return SystemUtils.IS_OS_MAC ? DEFAULT_MOUNTROOTPATH_MAC : DEFAULT_MOUNTROOTPATH_LINUX;
+			}
+
 		}
+		return null;
 	}
 
 	@Override

+ 13 - 13
main/ui/src/main/java/org/cryptomator/ui/model/Vault.java

@@ -56,17 +56,17 @@ public class Vault {
 	private final AtomicReference<CryptoFileSystem> cryptoFileSystem = new AtomicReference<>();
 	private final ObjectProperty<State> state = new SimpleObjectProperty<State>(State.LOCKED);
 
-	private NioAdapter nioAdapter;
+	private Volume volume;
 
 	public enum State {
 		LOCKED, UNLOCKED, MOUNTING, MOUNTED, UNMOUNTING
 	}
 
 	@Inject
-	Vault(Settings settings, VaultSettings vaultSettings, NioAdapter nioAdapter) {
+	Vault(Settings settings, VaultSettings vaultSettings, Volume volume) {
 		this.settings = settings;
 		this.vaultSettings = vaultSettings;
-		this.nioAdapter = nioAdapter;
+		this.volume = volume;
 	}
 
 	// ******************************************************************************
@@ -100,7 +100,7 @@ public class Vault {
 
 	public synchronized void unlock(CharSequence passphrase) throws CryptoException, IOException {
 		CryptoFileSystem fs = getCryptoFileSystem(passphrase);
-		nioAdapter.prepare(fs);
+		volume.prepare(fs);
 		Platform.runLater(() -> {
 			state.set(State.UNLOCKED);
 		});
@@ -110,7 +110,7 @@ public class Vault {
 		Platform.runLater(() -> {
 			state.set(State.MOUNTING);
 		});
-		nioAdapter.mount();
+		volume.mount();
 		Platform.runLater(() -> {
 			state.set(State.MOUNTED);
 		});
@@ -128,10 +128,10 @@ public class Vault {
 		Platform.runLater(() -> {
 			state.set(State.UNMOUNTING);
 		});
-		if (forced && nioAdapter.supportsForcedUnmount()) {
-			nioAdapter.unmountForced();
+		if (forced && volume.supportsForcedUnmount()) {
+			volume.unmountForced();
 		} else {
-			nioAdapter.unmount();
+			volume.unmount();
 		}
 		Platform.runLater(() -> {
 			state.set(State.UNLOCKED);
@@ -139,7 +139,7 @@ public class Vault {
 	}
 
 	public synchronized void lock() throws IOException {
-		nioAdapter.stop();
+		volume.stop();
 		CryptoFileSystem fs = cryptoFileSystem.getAndSet(null);
 		if (fs != null) {
 			fs.close();
@@ -156,7 +156,7 @@ public class Vault {
 		try {
 			unmount();
 		} catch (CommandFailedException e) {
-			if (nioAdapter.supportsForcedUnmount()) {
+			if (volume.supportsForcedUnmount()) {
 				try {
 					unmountForced();
 				} catch (CommandFailedException e1) {
@@ -174,7 +174,7 @@ public class Vault {
 	}
 
 	public void reveal() throws CommandFailedException {
-		nioAdapter.reveal();
+		volume.reveal();
 	}
 
 	// ******************************************************************************
@@ -290,7 +290,7 @@ public class Vault {
 	}
 
 	public String getFilesystemRootUrl() {
-		return nioAdapter.getMountUri();
+		return volume.getMountUri();
 	}
 
 	public String getId() {
@@ -317,6 +317,6 @@ public class Vault {
 	}
 
 	public boolean supportsForcedUnmount() {
-		return nioAdapter.supportsForcedUnmount();
+		return volume.supportsForcedUnmount();
 	}
 }

+ 3 - 3
main/ui/src/main/java/org/cryptomator/ui/model/VaultModule.java

@@ -43,13 +43,13 @@ public class VaultModule {
 
 	@Provides
 	@PerVault
-	public NioAdapter provideNioAdpater(Settings settings, WebDavNioAdapter webDavNioAdapter, FuseNioAdapter fuseNioAdapter) {
+	public Volume provideNioAdpater(Settings settings, WebDavVolume webDavVolume, FuseVolume fuseVolume) {
 		NioAdapterImpl impl = NioAdapterImpl.valueOf(settings.usedNioAdapterImpl().get());
 		switch (impl) {
 			case WEBDAV:
-				return webDavNioAdapter;
+				return webDavVolume;
 			case FUSE:
-				return fuseNioAdapter;
+				return fuseVolume;
 			default:
 				//this should not happen!
 				throw new IllegalStateException("Unsupported NioAdapter: " + settings.usedNioAdapterImpl().get());

+ 4 - 1
main/ui/src/main/java/org/cryptomator/ui/model/NioAdapter.java

@@ -2,7 +2,10 @@ package org.cryptomator.ui.model;
 
 import org.cryptomator.cryptofs.CryptoFileSystem;
 
-public interface NioAdapter {
+/**
+ * Takes a Volume and usess it to mount an unlocked vault
+ */
+public interface Volume {
 
 	void prepare(CryptoFileSystem fs);
 

+ 2 - 2
main/ui/src/main/java/org/cryptomator/ui/model/WebDavNioAdapter.java

@@ -14,7 +14,7 @@ import java.net.InetAddress;
 import java.net.UnknownHostException;
 
 @VaultModule.PerVault
-public class WebDavNioAdapter implements NioAdapter {
+public class WebDavVolume implements Volume {
 
 	private static final String LOCALHOST_ALIAS = "cryptomator-vault";
 
@@ -26,7 +26,7 @@ public class WebDavNioAdapter implements NioAdapter {
 	private Mounter.Mount mount;
 
 	@Inject
-	public WebDavNioAdapter(WebDavServer server, VaultSettings vaultSettings, Settings settings) {
+	public WebDavVolume(WebDavServer server, VaultSettings vaultSettings, Settings settings) {
 		this.server = server;
 		this.vaultSettings = vaultSettings;
 		this.settings = settings;

+ 4 - 4
main/ui/src/main/resources/fxml/settings.fxml

@@ -41,11 +41,11 @@
 			<CheckBox GridPane.rowIndex="1" GridPane.columnIndex="1" fx:id="debugModeCheckbox" cacheShape="true" cache="true" />
 
 			<!-- Row 2 -->
-			<Label fx:id="nioAdapterLabel" GridPane.rowIndex="2" GridPane.columnIndex="0" text="%settings.nioAdapter.label" cacheShape="true" cache="true" />
-			<ChoiceBox GridPane.rowIndex="2" GridPane.columnIndex="1" fx:id="nioAdapter" cacheShape="true" cache="true" />
+			<Label fx:id="volumeLabel" GridPane.rowIndex="2" GridPane.columnIndex="0" text="%settings.volume.label" cacheShape="true" cache="true" />
+			<ChoiceBox GridPane.rowIndex="2" GridPane.columnIndex="1" fx:id="volume" cacheShape="true" cache="true" />
 
 			<!-- Row 3 Alt 1-->
-			<GridPane fx:id="webdavNioAdapter" vgap="12.0" hgap="12.0" GridPane.rowIndex="3" GridPane.columnIndex="0" GridPane.columnSpan="2" visible="true" cacheShape="true" cache="true">
+			<GridPane fx:id="webdavVolume" vgap="12.0" hgap="12.0" GridPane.rowIndex="3" GridPane.columnIndex="0" GridPane.columnSpan="2" visible="true" cacheShape="true" cache="true">
 				<Label fx:id="portFieldLabel" GridPane.rowIndex="3" GridPane.columnIndex="0" text="%settings.webdav.port.label" cacheShape="true" cache="true" />
 				<HBox GridPane.rowIndex="3" GridPane.columnIndex="1" spacing="6.0">
 					<TextField  fx:id="portField" cacheShape="true" cache="true" promptText="%settings.webdav.port.prompt" />
@@ -58,7 +58,7 @@
 			</GridPane>
 
 			<!-- Row 3 Alt 2-->
-			<GridPane fx:id="fuseNioAdapter" vgap="12.0" hgap="12.0" GridPane.rowIndex="3" GridPane.columnIndex="0" GridPane.columnSpan="2" visible="false" cacheShape="true" cache="true">
+			<GridPane fx:id="fuseVolume" vgap="12.0" hgap="12.0" GridPane.rowIndex="3" GridPane.columnIndex="0" GridPane.columnSpan="2" visible="false" cacheShape="true" cache="true">
 			</GridPane>
 
 		</children>

+ 3 - 3
main/ui/src/main/resources/localization/en.txt

@@ -119,9 +119,9 @@ settings.webdav.port.apply=Apply
 settings.webdav.prefGvfsScheme.label=WebDAV Scheme
 settings.debugMode.label=Debug Mode *
 settings.requiresRestartLabel=* Cryptomator needs to restart
-settings.nioAdapter.label= Mount-Methode *
-settings.nioAdapter.webdav=WebDAV
-settings.nioAdapter.fuse=FUSE
+settings.volume.label= Mount-Methode *
+settings.volume.webdav=WebDAV
+settings.volume.fuse=FUSE
 
 # tray icon
 tray.menu.open=Open