mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-18 02:31:27 +00:00
Added base classes for MountPointChoosers and added module to component
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
package org.cryptomator.common.mountpoint;
|
||||
|
||||
public class InvalidMountPointException extends Exception {
|
||||
|
||||
public InvalidMountPointException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public InvalidMountPointException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public InvalidMountPointException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package org.cryptomator.common.mountpoint;
|
||||
|
||||
import dagger.MapKey;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface MountPointChooser {
|
||||
|
||||
default boolean isApplicable() {
|
||||
return true; //Usually most of the choosers should be applicable
|
||||
}
|
||||
|
||||
Optional<Path> chooseMountPoint();
|
||||
|
||||
default boolean prepare(Path mountPoint) throws InvalidMountPointException {
|
||||
return false; //NO-OP
|
||||
}
|
||||
|
||||
default void cleanup(Path mountPoint) {
|
||||
//NO-OP
|
||||
}
|
||||
|
||||
enum Phase {
|
||||
|
||||
CUSTOM_MOUNTPOINT(0),
|
||||
|
||||
CUSTOM_DRIVELETTER(1),
|
||||
|
||||
AVAILABLE_DRIVELETTER(2),
|
||||
|
||||
TEMPORARY_MOUNTPOINT(3);
|
||||
|
||||
private final int timing;
|
||||
|
||||
Phase(int timing) {
|
||||
this.timing = timing;
|
||||
}
|
||||
|
||||
public int getTiming() {
|
||||
return timing;
|
||||
}
|
||||
}
|
||||
|
||||
@MapKey
|
||||
@interface PhaseKey {
|
||||
|
||||
Phase value();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package org.cryptomator.common.mountpoint;
|
||||
|
||||
import dagger.Module;
|
||||
|
||||
@Module
|
||||
public abstract class MountPointChooserModule {
|
||||
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
package org.cryptomator.common.vaults;
|
||||
|
||||
import dagger.BindsInstance;
|
||||
import org.cryptomator.common.mountpoint.MountPointChooserModule;
|
||||
import org.cryptomator.common.settings.VaultSettings;
|
||||
|
||||
import dagger.Subcomponent;
|
||||
@@ -14,7 +15,7 @@ import javax.annotation.Nullable;
|
||||
import javax.inject.Named;
|
||||
|
||||
@PerVault
|
||||
@Subcomponent(modules = {VaultModule.class})
|
||||
@Subcomponent(modules = {VaultModule.class, MountPointChooserModule.class})
|
||||
public interface VaultComponent {
|
||||
|
||||
Vault vault();
|
||||
|
||||
Reference in New Issue
Block a user