- restored progress indicator, broken by previous commit
This commit is contained in:
Sebastian Stenzel
2015-10-04 22:01:01 +02:00
parent 1bef4e786d
commit 104c3b64f6
10 changed files with 87 additions and 17 deletions
@@ -29,6 +29,7 @@ import org.cryptomator.crypto.exceptions.WrongPasswordException;
import org.cryptomator.ui.controls.SecPasswordField;
import org.cryptomator.ui.model.Vault;
import org.cryptomator.ui.util.FXThreads;
import org.cryptomator.ui.util.mount.CommandFailedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -170,14 +171,23 @@ public class UnlockController extends AbstractFXMLViewController {
final Future<Boolean> futureMount = exec.submit(() -> (boolean) vault.mount());
FXThreads.runOnMainThreadWhenFinished(exec, futureMount, this::unlockAndMountFinished);
} catch (IOException ex) {
setControlsDisabled(false);
progressIndicator.setVisible(false);
messageText.setText(resourceBundle.getString("unlock.errorMessage.decryptionFailed"));
LOG.error("Decryption failed for technical reasons.", ex);
} catch (WrongPasswordException e) {
setControlsDisabled(false);
progressIndicator.setVisible(false);
messageText.setText(resourceBundle.getString("unlock.errorMessage.wrongPassword"));
Platform.runLater(passwordField::requestFocus);
} catch (UnsupportedKeyLengthException ex) {
setControlsDisabled(false);
progressIndicator.setVisible(false);
messageText.setText(resourceBundle.getString("unlock.errorMessage.unsupportedKeyLengthInstallJCE"));
LOG.warn("Unsupported Key-Length. Please install Oracle Java Cryptography Extension (JCE).", ex);
} catch (UnsupportedVaultException e) {
setControlsDisabled(false);
progressIndicator.setVisible(false);
downloadsPageLink.setVisible(true);
if (e.isVaultOlderThanSoftware()) {
messageText.setText(resourceBundle.getString("unlock.errorMessage.unsupportedVersion.vaultOlderThanSoftware") + " ");
@@ -185,12 +195,11 @@ public class UnlockController extends AbstractFXMLViewController {
messageText.setText(resourceBundle.getString("unlock.errorMessage.unsupportedVersion.softwareOlderThanVault") + " ");
}
} catch (DestroyFailedException e) {
LOG.error("Destruction of cryptor threw an exception.", e);
} finally {
setControlsDisabled(false);
progressIndicator.setVisible(false);
LOG.error("Destruction of cryptor threw an exception.", e);
} finally {
passwordField.swipe();
Platform.runLater(passwordField::requestFocus);
}
}
@@ -207,6 +216,12 @@ public class UnlockController extends AbstractFXMLViewController {
if (vault.isUnlocked() && !mountSuccess) {
vault.stopServer();
vault.setUnlocked(false);
} else if (vault.isUnlocked() && mountSuccess) {
try {
vault.reveal();
} catch (CommandFailedException e) {
LOG.error("Failed to reveal mounted vault", e);
}
}
if (mountSuccess && listener != null) {
listener.didUnlock(this);
@@ -76,6 +76,16 @@ public class UnlockedController extends AbstractFXMLViewController {
ActiveWindowStyleSupport.startObservingFocus(macWarningsWindow);
}
@FXML
private void didClickRevealVault(ActionEvent event) {
try {
vault.reveal();
} catch (CommandFailedException e) {
messageLabel.setText(resourceBundle.getString("unlocked.label.revealFailed"));
return;
}
}
@FXML
private void didClickCloseVault(ActionEvent event) {
try {
@@ -10,11 +10,6 @@ import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javax.security.auth.DestroyFailedException;
import org.apache.commons.lang3.StringUtils;
@@ -30,6 +25,11 @@ import org.cryptomator.webdav.WebDavServer.ServletLifeCycleAdapter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
public class Vault implements Serializable {
private static final long serialVersionUID = 3754487289683599469L;
@@ -123,6 +123,13 @@ public class Vault implements Serializable {
}
}
public void reveal() throws CommandFailedException {
final WebDavMount mnt = webDavMount.get().orElse(null);
if (mnt != null) {
mnt.reveal();
}
}
public void unmount() throws CommandFailedException {
final WebDavMount mnt = webDavMount.get().orElse(null);
if (mnt != null) {
@@ -35,6 +35,11 @@ final class FallbackWebDavMounter implements WebDavMounterStrategy {
public void unmount() {
displayUnmountInstructions();
}
@Override
public void reveal() throws CommandFailedException {
displayRevealInstructions();
}
};
}
@@ -47,4 +52,8 @@ final class FallbackWebDavMounter implements WebDavMounterStrategy {
// TODO display message to user pointing to cryptomator.org/mounting#unmount which describes what to do
}
private void displayRevealInstructions() {
// TODO display message to user pointing to cryptomator.org/mounting#reveal which describes what to do
}
}
@@ -52,11 +52,6 @@ final class LinuxGvfsWebDavMounter implements WebDavMounterStrategy {
"gvfs-mount -u \"dav:$DAV_SSP\"")
.addEnv("DAV_SSP", uri.getRawSchemeSpecificPart());
mountScript.execute();
try{
openMountWithWebdavUri("dav:"+uri.getRawSchemeSpecificPart()).execute();
}catch(CommandFailedException exception){
openMountWithWebdavUri("webdav:"+uri.getRawSchemeSpecificPart()).execute();
}
return new AbstractWebDavMount() {
@Override
public void unmount() throws CommandFailedException {
@@ -72,6 +67,15 @@ final class LinuxGvfsWebDavMounter implements WebDavMounterStrategy {
unmountScript.execute();
}
}
@Override
public void reveal() throws CommandFailedException {
try {
openMountWithWebdavUri("dav:"+uri.getRawSchemeSpecificPart()).execute();
} catch (CommandFailedException exception) {
openMountWithWebdavUri("webdav:"+uri.getRawSchemeSpecificPart()).execute();
}
}
};
}
@@ -35,12 +35,14 @@ final class MacOsXWebDavMounter implements WebDavMounterStrategy {
final String path = "/Volumes/Cryptomator_" + UUID.randomUUID().toString();
final Script mountScript = Script.fromLines(
"mkdir \"$MOUNT_PATH\"",
"mount_webdav -S -v $MOUNT_NAME \"$DAV_AUTHORITY$DAV_PATH\" \"$MOUNT_PATH\"",
"open \"$MOUNT_PATH\"")
"mount_webdav -S -v $MOUNT_NAME \"$DAV_AUTHORITY$DAV_PATH\" \"$MOUNT_PATH\"")
.addEnv("DAV_AUTHORITY", uri.getRawAuthority())
.addEnv("DAV_PATH", uri.getRawPath())
.addEnv("MOUNT_PATH", path)
.addEnv("MOUNT_NAME", name);
final Script revealScript = Script.fromLines(
"open \"$MOUNT_PATH\"")
.addEnv("MOUNT_PATH", path);
final Script unmountScript = Script.fromLines(
"diskutil umount $MOUNT_PATH")
.addEnv("MOUNT_PATH", path);
@@ -53,6 +55,11 @@ final class MacOsXWebDavMounter implements WebDavMounterStrategy {
unmountScript.execute();
}
}
@Override
public void reveal() throws CommandFailedException {
revealScript.execute();
}
};
}
@@ -22,4 +22,11 @@ public interface WebDavMount extends AutoCloseable {
*/
void unmount() throws CommandFailedException;
/**
* Reveals the mounted drive in the operating systems default file browser.
*
* @throws CommandFailedException if the reveal operation fails
*/
void reveal() throws CommandFailedException;
}
@@ -61,7 +61,6 @@ final class WindowsWebDavMounter implements WebDavMounterStrategy {
final String driveLetter = getDriveLetter(mountResult.getStdOut());
final Script openExplorerScript = fromLines("start explorer.exe " + driveLetter);
openExplorerScript.execute();
final Script unmountScript = fromLines("net use " + driveLetter + " /delete").addEnv("DRIVE_LETTER", driveLetter);
return new AbstractWebDavMount() {
@Override
@@ -71,6 +70,11 @@ final class WindowsWebDavMounter implements WebDavMounterStrategy {
unmountScript.execute();
}
}
@Override
public void reveal() throws CommandFailedException {
openExplorerScript.execute();
}
};
}
@@ -16,6 +16,7 @@
<?import javafx.scene.layout.GridPane?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.HBox?>
<GridPane vgap="12.0" hgap="12.0" prefWidth="400.0" xmlns:fx="http://javafx.com/fxml">
<padding>
@@ -36,7 +37,11 @@
<!-- Row 1 -->
<Label fx:id="messageLabel" GridPane.rowIndex="1" GridPane.columnIndex="0" />
<Button text="%unlocked.button.lock" GridPane.rowIndex="1" GridPane.columnIndex="1" GridPane.halignment="RIGHT" prefWidth="150.0" onAction="#didClickCloseVault" focusTraversable="false"/>
<HBox GridPane.rowIndex="1" GridPane.columnIndex="1" spacing="6.0" alignment="CENTER_RIGHT">
<Button text="%unlocked.button.reveal" prefWidth="100.0" onAction="#didClickRevealVault" focusTraversable="false"/>
<Button text="%unlocked.button.lock" prefWidth="100.0" onAction="#didClickCloseVault" focusTraversable="false"/>
</HBox>
</children>
</GridPane>
@@ -56,7 +56,9 @@ changePassword.errorMessage.unsupportedVersion.softwareOlderThanVault=Unsupporte
changePassword.infoMessage.success=Password changed.
# unlocked.fxml
unlocked.button.reveal=Reveal drive
unlocked.button.lock=Lock vault
unlocked.label.revealFailed=Command failed.
unlocked.label.unmountFailed=Ejecting drive failed.
unlocked.ioGraph.yAxis.label=Throughput (MiB/s)