diff --git a/src/main/java/org/cryptomator/common/vaults/Vault.java b/src/main/java/org/cryptomator/common/vaults/Vault.java index f857d6ba1..7b66cea3d 100644 --- a/src/main/java/org/cryptomator/common/vaults/Vault.java +++ b/src/main/java/org/cryptomator/common/vaults/Vault.java @@ -412,6 +412,16 @@ public class Vault { } } + /** + */ + public String getCleartextName(Path ciphertextPath) throws IOException { + if (!state.getValue().equals(VaultState.Value.UNLOCKED)) { + throw new IllegalStateException("Vault is not unlocked"); + } + var fs = cryptoFileSystem.get(); + return fs.getCleartextName(ciphertextPath); + } + public VaultConfigCache getVaultConfigCache() { return configCache; } diff --git a/src/main/java/org/cryptomator/ui/controls/FontAwesome5Icon.java b/src/main/java/org/cryptomator/ui/controls/FontAwesome5Icon.java index 485e89304..337f653dd 100644 --- a/src/main/java/org/cryptomator/ui/controls/FontAwesome5Icon.java +++ b/src/main/java/org/cryptomator/ui/controls/FontAwesome5Icon.java @@ -8,6 +8,8 @@ public enum FontAwesome5Icon { ARROW_UP("\uF062"), // BAN("\uF05E"), // BUG("\uF188"), // + BULLSEYE("\uF140"), // + DOT_CIRCLE("\uF192"), // CARET_DOWN("\uF0D7"), // CARET_RIGHT("\uF0Da"), // CHECK("\uF00C"), // diff --git a/src/main/java/org/cryptomator/ui/mainwindow/VaultDetailUnlockedController.java b/src/main/java/org/cryptomator/ui/mainwindow/VaultDetailUnlockedController.java index ef6148c87..2e935eb25 100644 --- a/src/main/java/org/cryptomator/ui/mainwindow/VaultDetailUnlockedController.java +++ b/src/main/java/org/cryptomator/ui/mainwindow/VaultDetailUnlockedController.java @@ -26,13 +26,16 @@ import javafx.beans.property.ReadOnlyObjectProperty; import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.value.ObservableValue; import javafx.fxml.FXML; +import javafx.scene.control.Alert; import javafx.scene.control.Button; +import javafx.scene.control.ButtonType; import javafx.scene.input.Clipboard; import javafx.scene.input.ClipboardContent; import javafx.scene.input.DataFormat; import javafx.scene.input.DragEvent; import javafx.scene.input.TransferMode; import javafx.stage.FileChooser; +import javafx.stage.Popup; import javafx.stage.Stage; import java.io.File; import java.io.IOException; @@ -110,6 +113,7 @@ public class VaultDetailUnlockedController implements FxController { draggingOver.set(true); } else if (DragEvent.DRAG_DROPPED.equals(event.getEventType()) && event.getGestureSource() == null && event.getDragboard().hasFiles()) { List ciphertextPaths = event.getDragboard().getFiles().stream().map(File::toPath).map(this::getCiphertextPath).flatMap(Optional::stream).toList(); + //TODO: differ between encrypted and decrypted files if (ciphertextPaths.isEmpty()) { wrongFileAlert.build().showWrongFileAlertWindow(); } else { @@ -161,6 +165,26 @@ public class VaultDetailUnlockedController implements FxController { } } + @FXML + public void chooseEncryptedFileAndGetName() { + var fileChooser = new FileChooser(); + fileChooser.setTitle(resourceBundle.getString("main.vaultDetail.filePickerTitle")); + + fileChooser.setInitialDirectory(vault.getValue().getPath().toFile()); + var ciphertextNode = fileChooser.showOpenDialog(mainWindow); + try { + var nodeName = vault.get().getCleartextName(ciphertextNode.toPath()); + var alert = new Alert(Alert.AlertType.INFORMATION, "The answer is: %s".formatted(nodeName), ButtonType.OK); + alert.showAndWait(); + //.filter(response -> response == ButtonType.OK) + //.ifPresent(response -> formatSystem()); + } catch (Exception e) { + LOG.warn("Failed to decrypt filename for {}", ciphertextNode, e); + var alert = new Alert(Alert.AlertType.ERROR, "The exception is: %s".formatted(e.getClass()), ButtonType.OK); + alert.showAndWait(); + } + } + private boolean startsWithVaultAccessPoint(Path path) { return path.startsWith(Path.of(mountPoint.getValue())); } diff --git a/src/main/resources/fxml/vault_detail_unlocked.fxml b/src/main/resources/fxml/vault_detail_unlocked.fxml index c035b2d88..37c6d2101 100644 --- a/src/main/resources/fxml/vault_detail_unlocked.fxml +++ b/src/main/resources/fxml/vault_detail_unlocked.fxml @@ -7,6 +7,7 @@ + - - - - - - - + + + + + + + + + + + + + + + +