Skip to content

Commit

Permalink
renaming NioAdapter-Interface to Volume to prevent confusing to FUSE-…
Browse files Browse the repository at this point in the history
…project
  • Loading branch information
infeo committed Mar 1, 2018
1 parent 3bc7df9 commit 242b1e9
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 50 deletions.
2 changes: 1 addition & 1 deletion main/pom.xml
Expand Up @@ -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>
Expand Down
Expand Up @@ -56,10 +56,10 @@ public SettingsController(Localization localization, Settings settings, @Named("
private CheckBox checkForUpdatesCheckbox;

@FXML
private GridPane webdavNioAdapter;
private GridPane webdavVolume;

@FXML
private GridPane fuseNioAdapter;
private GridPane fuseVolume;

@FXML
private Label portFieldLabel;
Expand All @@ -80,7 +80,7 @@ public SettingsController(Localization localization, Settings settings, @Named("
private ChoiceBox<String> prefGvfsScheme;

@FXML
private Label nioAdapterLabel;
private Label volumeLabel;

@FXML
private ChoiceBox<String> nioAdapter;
Expand All @@ -105,12 +105,12 @@ public void initialize() {


//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()));
Expand All @@ -122,7 +122,7 @@ public void initialize() {
prefGvfsScheme.setVisible(SystemUtils.IS_OS_LINUX);

//FUSE
fuseNioAdapter.managedProperty().bind(fuseNioAdapter.visibleProperty());
fuseVolume.managedProperty().bind(fuseVolume.visibleProperty());

debugModeCheckbox.setSelected(settings.debugMode().get());

Expand All @@ -138,8 +138,8 @@ private String[] getSupportedAdapters() {
}

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
Expand Down
Expand Up @@ -14,9 +14,11 @@
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;
Expand All @@ -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();
Expand All @@ -44,22 +46,35 @@ public void mount() throws CommandFailedException {
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) {
throw new CommandFailedException("Unable to mount Filesystem", e);
}
}

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
Expand Down
26 changes: 13 additions & 13 deletions main/ui/src/main/java/org/cryptomator/ui/model/Vault.java
Expand Up @@ -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;
}

// ******************************************************************************
Expand Down Expand Up @@ -100,7 +100,7 @@ public void changePassphrase(CharSequence oldPassphrase, CharSequence newPassphr

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);
});
Expand All @@ -110,7 +110,7 @@ public synchronized void mount() throws CommandFailedException {
Platform.runLater(() -> {
state.set(State.MOUNTING);
});
nioAdapter.mount();
volume.mount();
Platform.runLater(() -> {
state.set(State.MOUNTED);
});
Expand All @@ -128,18 +128,18 @@ private synchronized void unmount(boolean forced) throws CommandFailedException
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);
});
}

public synchronized void lock() throws IOException {
nioAdapter.stop();
volume.stop();
CryptoFileSystem fs = cryptoFileSystem.getAndSet(null);
if (fs != null) {
fs.close();
Expand All @@ -156,7 +156,7 @@ public void prepareForShutdown() {
try {
unmount();
} catch (CommandFailedException e) {
if (nioAdapter.supportsForcedUnmount()) {
if (volume.supportsForcedUnmount()) {
try {
unmountForced();
} catch (CommandFailedException e1) {
Expand All @@ -174,7 +174,7 @@ public void prepareForShutdown() {
}

public void reveal() throws CommandFailedException {
nioAdapter.reveal();
volume.reveal();
}

// ******************************************************************************
Expand Down Expand Up @@ -290,7 +290,7 @@ public void setWinDriveLetter(Character winDriveLetter) {
}

public String getFilesystemRootUrl() {
return nioAdapter.getMountUri();
return volume.getMountUri();
}

public String getId() {
Expand All @@ -317,6 +317,6 @@ public boolean equals(Object obj) {
}

public boolean supportsForcedUnmount() {
return nioAdapter.supportsForcedUnmount();
return volume.supportsForcedUnmount();
}
}
Expand Up @@ -43,13 +43,13 @@ public VaultSettings provideVaultSettings() {

@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());
Expand Down
Expand Up @@ -2,7 +2,10 @@

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);

Expand Down
Expand Up @@ -14,7 +14,7 @@
import java.net.UnknownHostException;

@VaultModule.PerVault
public class WebDavNioAdapter implements NioAdapter {
public class WebDavVolume implements Volume {

private static final String LOCALHOST_ALIAS = "cryptomator-vault";

Expand All @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions main/ui/src/main/resources/fxml/settings.fxml
Expand Up @@ -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" />
Expand All @@ -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>
Expand Down
6 changes: 3 additions & 3 deletions main/ui/src/main/resources/localization/en.txt
Expand Up @@ -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
Expand Down

0 comments on commit 242b1e9

Please sign in to comment.