diff --git a/main/commons/src/main/java/org/cryptomator/common/vaults/DokanyVolume.java b/main/commons/src/main/java/org/cryptomator/common/vaults/DokanyVolume.java index e0379e9db..a33dbd5ee 100644 --- a/main/commons/src/main/java/org/cryptomator/common/vaults/DokanyVolume.java +++ b/main/commons/src/main/java/org/cryptomator/common/vaults/DokanyVolume.java @@ -52,10 +52,11 @@ public class DokanyVolume extends AbstractVolume { } @Override - public void reveal() throws VolumeException { - boolean success = mount.reveal(); - if (!success) { - throw new VolumeException("Reveal failed."); + public void reveal(Revealer revealer) throws VolumeException { + try { + mount.reveal(revealer::reveal); + } catch (Exception e) { + throw new VolumeException(e); } } @@ -79,6 +80,7 @@ public class DokanyVolume extends AbstractVolume { public boolean supportsForcedUnmount() { return true; } + @Override public boolean isSupported() { return DokanyVolume.isSupportedStatic(); diff --git a/main/commons/src/main/java/org/cryptomator/common/vaults/FuseVolume.java b/main/commons/src/main/java/org/cryptomator/common/vaults/FuseVolume.java index e5c49d025..5400f8ff2 100644 --- a/main/commons/src/main/java/org/cryptomator/common/vaults/FuseVolume.java +++ b/main/commons/src/main/java/org/cryptomator/common/vaults/FuseVolume.java @@ -20,7 +20,6 @@ import javax.inject.Named; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; -import java.util.SortedSet; import java.util.regex.Pattern; public class FuseVolume extends AbstractVolume { @@ -73,11 +72,10 @@ public class FuseVolume extends AbstractVolume { } @Override - public void reveal() throws VolumeException { + public void reveal(Revealer revealer) throws VolumeException { try { - mount.revealInFileManager(); - } catch (CommandFailedException e) { - LOG.debug("Revealing the vault in file manger failed: " + e.getMessage()); + mount.reveal(revealer::reveal); + } catch (Exception e) { throw new VolumeException(e); } } diff --git a/main/commons/src/main/java/org/cryptomator/common/vaults/Vault.java b/main/commons/src/main/java/org/cryptomator/common/vaults/Vault.java index bf268eda0..f3b058198 100644 --- a/main/commons/src/main/java/org/cryptomator/common/vaults/Vault.java +++ b/main/commons/src/main/java/org/cryptomator/common/vaults/Vault.java @@ -157,8 +157,8 @@ public class Vault { destroyCryptoFileSystem(); } - public void reveal() throws VolumeException { - volume.reveal(); + public void reveal(Volume.Revealer vaultRevealer) throws VolumeException { + volume.reveal(vaultRevealer); } // ****************************************************************************** diff --git a/main/commons/src/main/java/org/cryptomator/common/vaults/Volume.java b/main/commons/src/main/java/org/cryptomator/common/vaults/Volume.java index 624efea13..74a307d5a 100644 --- a/main/commons/src/main/java/org/cryptomator/common/vaults/Volume.java +++ b/main/commons/src/main/java/org/cryptomator/common/vaults/Volume.java @@ -34,7 +34,15 @@ public interface Volume { */ void mount(CryptoFileSystem fs, String mountFlags) throws IOException, VolumeException, InvalidMountPointException; - void reveal() throws VolumeException; + /** + * Reveals the mounted volume. + *

+ * The given {@code revealer} might be used to do it, but not necessarily. + * + * @param revealer An object capable of revealing the location of the mounted vault to view the content (e.g. in the default file browser). + * @throws VolumeException + */ + void reveal(Revealer revealer) throws VolumeException; void unmount() throws VolumeException; @@ -79,4 +87,14 @@ public interface Volume { } + /** + * Hides and unifies the different Revealer implementations in the different nio-adapters. + */ + @FunctionalInterface + interface Revealer { + + void reveal(Path p) throws VolumeException; + + } + } diff --git a/main/commons/src/main/java/org/cryptomator/common/vaults/WebDavVolume.java b/main/commons/src/main/java/org/cryptomator/common/vaults/WebDavVolume.java index ff0bc1632..8b4f27fdb 100644 --- a/main/commons/src/main/java/org/cryptomator/common/vaults/WebDavVolume.java +++ b/main/commons/src/main/java/org/cryptomator/common/vaults/WebDavVolume.java @@ -31,7 +31,6 @@ public class WebDavVolume implements Volume { private WebDavServer server; private WebDavServletController servlet; private Mounter.Mount mount; - private Path mountPoint; @Inject public WebDavVolume(Provider serverProvider, VaultSettings vaultSettings, Settings settings, WindowsDriveLetters windowsDriveLetters) { @@ -86,11 +85,10 @@ public class WebDavVolume implements Volume { } @Override - public void reveal() throws VolumeException { + public void reveal(Revealer revealer) throws VolumeException { try { - mount.reveal(); - } catch (Mounter.CommandFailedException e) { - e.printStackTrace(); + mount.reveal(revealer::reveal); + } catch (Exception e) { throw new VolumeException(e); } } @@ -117,7 +115,7 @@ public class WebDavVolume implements Volume { @Override public Optional getMountPoint() { - return Optional.ofNullable(mountPoint); //TODO + return mount.getMountPoint(); } @Override diff --git a/main/pom.xml b/main/pom.xml index 0be3baa81..fbeed196e 100644 --- a/main/pom.xml +++ b/main/pom.xml @@ -29,9 +29,9 @@ 0.2.1 0.1.0-beta3 0.1.0-beta2 - 1.2.6 - 1.2.1 - 1.0.14 + 1.2.8 + 1.2.3 + 1.1.1 15 diff --git a/main/ui/src/main/java/org/cryptomator/ui/common/HostServiceRevealer.java b/main/ui/src/main/java/org/cryptomator/ui/common/HostServiceRevealer.java new file mode 100644 index 000000000..829480592 --- /dev/null +++ b/main/ui/src/main/java/org/cryptomator/ui/common/HostServiceRevealer.java @@ -0,0 +1,25 @@ +package org.cryptomator.ui.common; + +import dagger.Lazy; +import org.cryptomator.common.vaults.Volume; +import org.cryptomator.ui.fxapp.FxApplicationScoped; + +import javax.inject.Inject; +import javafx.application.Application; +import java.nio.file.Path; + +@FxApplicationScoped +public class HostServiceRevealer implements Volume.Revealer { + + private final Lazy application; + + @Inject + public HostServiceRevealer(Lazy application) { + this.application = application; + } + + @Override + public void reveal(Path p) throws Volume.VolumeException { + application.get().getHostServices().showDocument(p.toUri().toString()); + } +} diff --git a/main/ui/src/main/java/org/cryptomator/ui/common/VaultService.java b/main/ui/src/main/java/org/cryptomator/ui/common/VaultService.java index 1f4ffc3fd..57393b858 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/common/VaultService.java +++ b/main/ui/src/main/java/org/cryptomator/ui/common/VaultService.java @@ -23,10 +23,12 @@ public class VaultService { private static final Logger LOG = LoggerFactory.getLogger(VaultService.class); private final ExecutorService executorService; + private final HostServiceRevealer vaultRevealer; @Inject - public VaultService(ExecutorService executorService) { + public VaultService(ExecutorService executorService, HostServiceRevealer vaultRevealer) { this.executorService = executorService; + this.vaultRevealer = vaultRevealer; } public void reveal(Vault vault) { @@ -39,7 +41,7 @@ public class VaultService { * @param vault The vault to reveal */ public Task createRevealTask(Vault vault) { - Task task = new RevealVaultTask(vault); + Task task = new RevealVaultTask(vault, vaultRevealer); task.setOnSucceeded(evt -> LOG.info("Revealed {}", vault.getDisplayName())); task.setOnFailed(evt -> LOG.error("Failed to reveal " + vault.getDisplayName(), evt.getSource().getException())); return task; @@ -99,19 +101,22 @@ public class VaultService { private static class RevealVaultTask extends Task { private final Vault vault; + private final Volume.Revealer revealer; /** * @param vault The vault to lock + * @param revealer The object to use to show the vault content to the user. */ - public RevealVaultTask(Vault vault) { + public RevealVaultTask(Vault vault, Volume.Revealer revealer) { this.vault = vault; + this.revealer = revealer; setOnFailed(evt -> LOG.error("Failed to reveal " + vault.getDisplayName(), getException())); } @Override protected Vault call() throws Volume.VolumeException { - vault.reveal(); + vault.reveal(revealer); return vault; } } diff --git a/main/ui/src/main/java/org/cryptomator/ui/traymenu/TrayMenuComponent.java b/main/ui/src/main/java/org/cryptomator/ui/traymenu/TrayMenuComponent.java index a4e068f8d..c4cbfd456 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/traymenu/TrayMenuComponent.java +++ b/main/ui/src/main/java/org/cryptomator/ui/traymenu/TrayMenuComponent.java @@ -7,7 +7,6 @@ package org.cryptomator.ui.traymenu; import dagger.Lazy; import dagger.Subcomponent; - import java.awt.SystemTray; @TrayMenuScoped diff --git a/main/ui/src/main/resources/license/THIRD-PARTY.txt b/main/ui/src/main/resources/license/THIRD-PARTY.txt index b4f3ee28e..30a364776 100644 --- a/main/ui/src/main/resources/license/THIRD-PARTY.txt +++ b/main/ui/src/main/resources/license/THIRD-PARTY.txt @@ -11,7 +11,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. -Cryptomator uses 47 third-party dependencies under the following licenses: +Cryptomator uses 46 third-party dependencies under the following licenses: Apache License v2.0: - jffi (com.github.jnr:jffi:1.2.23 - http://github.com/jnr/jffi) - jnr-a64asm (com.github.jnr:jnr-a64asm:1.0.0 - http://nexus.sonatype.org/oss-repository-hosting.html/jnr-a64asm) @@ -26,7 +26,6 @@ Cryptomator uses 47 third-party dependencies under the following licenses: - Guava ListenableFuture only (com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava - https://github.com/google/guava/listenablefuture) - J2ObjC Annotations (com.google.j2objc:j2objc-annotations:1.3 - https://github.com/google/j2objc/) - Apache Commons CLI (commons-cli:commons-cli:1.4 - http://commons.apache.org/proper/commons-cli/) - - Apache Commons IO (commons-io:commons-io:2.6 - http://commons.apache.org/proper/commons-io/) - javax.inject (javax.inject:javax.inject:1 - http://code.google.com/p/atinject/) - Java Native Access (net.java.dev.jna:jna:5.6.0 - https://github.com/java-native-access/jna) - Java Native Access Platform (net.java.dev.jna:jna-platform:5.5.0 - https://github.com/java-native-access/jna)