Skip to content

Commit 4cfeb9e

Browse files
committed
Merge branch 'main' into develop
2 parents 703f5bf + 5c7515f commit 4cfeb9e

12 files changed

Lines changed: 325 additions & 70 deletions

File tree

pom.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>org.cryptomator</groupId>
77
<artifactId>integrations-api</artifactId>
8-
<version>1.2.0-SNAPSHOT</version>
8+
<version>1.3.0-SNAPSHOT</version>
99

1010
<name>Cryptomator Integrations API</name>
1111
<description>Defines optional service interfaces that may be used by Cryptomator</description>
@@ -92,6 +92,11 @@
9292
</execution>
9393
</executions>
9494
</plugin>
95+
<plugin>
96+
<groupId>org.apache.maven.plugins</groupId>
97+
<artifactId>maven-surefire-plugin</artifactId>
98+
<version>3.0.0-M7</version>
99+
</plugin>
95100
<plugin>
96101
<artifactId>maven-javadoc-plugin</artifactId>
97102
<version>3.2.0</version>

src/main/java/module-info.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import org.cryptomator.integrations.mount.MountProvider;
1+
import org.cryptomator.integrations.mount.MountService;
2+
import org.cryptomator.integrations.revealpath.RevealPathService;
23
import org.cryptomator.integrations.tray.TrayMenuController;
34
import org.cryptomator.integrations.autostart.AutoStartProvider;
45
import org.cryptomator.integrations.keychain.KeychainAccessProvider;
@@ -14,12 +15,14 @@
1415
exports org.cryptomator.integrations.common;
1516
exports org.cryptomator.integrations.keychain;
1617
exports org.cryptomator.integrations.mount;
18+
exports org.cryptomator.integrations.revealpath;
1719
exports org.cryptomator.integrations.tray;
1820
exports org.cryptomator.integrations.uiappearance;
1921

2022
uses AutoStartProvider;
2123
uses KeychainAccessProvider;
22-
uses MountProvider;
24+
uses MountService;
25+
uses RevealPathService;
2326
uses TrayIntegrationProvider;
2427
uses TrayMenuController;
2528
uses UiAppearanceProvider;

src/main/java/org/cryptomator/integrations/mount/Mount.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.cryptomator.integrations.mount;
22

3-
import java.nio.file.Path;
3+
import java.io.IOException;
44

55
/**
66
* Handle to control the lifecycle of a mounted file system.
@@ -14,7 +14,7 @@ public interface Mount extends AutoCloseable {
1414
*
1515
* @return Absolute path to the mountpoint.
1616
*/
17-
Path getMountpoint();
17+
Mountpoint getMountpoint();
1818

1919
/**
2020
* Unmounts the mounted Volume.
@@ -24,20 +24,26 @@ public interface Mount extends AutoCloseable {
2424
* @throws UnmountFailedException If the unmount was not successful.
2525
* @see #unmountForced()
2626
*/
27-
void unmout() throws UnmountFailedException;
27+
void unmount() throws UnmountFailedException;
2828

2929
/**
3030
* If supported, force-unmount the volume.
3131
*
3232
* @throws UnmountFailedException If the unmount was not successful.
33-
* @throws UnsupportedOperationException If {@link MountFeature#UNMOUNT_FORCED} is not supported
33+
* @throws UnsupportedOperationException If {@link MountCapability#UNMOUNT_FORCED} is not supported
3434
*/
3535
default void unmountForced() throws UnmountFailedException {
3636
throw new UnsupportedOperationException();
3737
}
3838

39-
default void close() throws UnmountFailedException {
40-
unmout();
39+
/**
40+
* Unmounts (if required) and releases any resources.
41+
*
42+
* @throws UnmountFailedException Thrown if unmounting failed
43+
* @throws IOException Thrown if cleaning up resources failed
44+
*/
45+
default void close() throws UnmountFailedException, IOException {
46+
unmount();
4147
}
4248

4349

src/main/java/org/cryptomator/integrations/mount/MountBuilder.java

Lines changed: 64 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,53 +13,108 @@
1313
*/
1414
public interface MountBuilder {
1515

16+
/**
17+
* Sets the file system name.
18+
*
19+
* @param fileSystemName file system name
20+
* @return <code>this</code>
21+
* @throws UnsupportedOperationException If {@link MountCapability#FILE_SYSTEM_NAME} is not supported
22+
*/
23+
@Contract("_ -> this")
24+
default MountBuilder setFileSystemName(String fileSystemName) {
25+
throw new UnsupportedOperationException();
26+
}
27+
28+
/**
29+
* Use the given host name as the loopback address.
30+
*
31+
* @param hostName string conforming with the uri host part
32+
* @return <code>this</code>
33+
* @throws UnsupportedOperationException If {@link MountCapability#LOOPBACK_HOST_NAME} is not supported
34+
*/
35+
@Contract("_ -> this")
36+
default MountBuilder setLoopbackHostName(String hostName) {
37+
throw new UnsupportedOperationException();
38+
}
39+
40+
/**
41+
* Use the given TCP port of the loopback address.
42+
*
43+
* @param port Fixed TCP port or 0 to use a system-assigned port
44+
* @return <code>this</code>
45+
* @throws UnsupportedOperationException If {@link MountCapability#LOOPBACK_PORT} is not supported
46+
*/
47+
@Contract("_ -> this")
48+
default MountBuilder setLoopbackPort(@Range(from = 0, to = Short.MAX_VALUE) int port) {
49+
throw new UnsupportedOperationException();
50+
}
51+
1652
/**
1753
* Sets the mount point.
54+
* <p>
55+
* Unless the mount service provider supports {@link MountCapability#MOUNT_TO_SYSTEM_CHOSEN_PATH}, setting a mount point is required.
1856
*
1957
* @param mountPoint Where to mount the volume
2058
* @return <code>this</code>
21-
* @see MountProvider#getDefaultMountPoint(String)
2259
*/
2360
@Contract("_ -> this")
24-
MountBuilder setMountpoint(Path mountPoint);
61+
default MountBuilder setMountpoint(Path mountPoint) {
62+
throw new UnsupportedOperationException();
63+
}
2564

2665
/**
2766
* Sets mount flags.
2867
*
2968
* @param mountFlags Mount flags
3069
* @return <code>this</code>
31-
* @throws UnsupportedOperationException If {@link MountFeature#MOUNT_FLAGS} is not supported
32-
* @see MountProvider#getDefaultMountFlags(String)
70+
* @throws UnsupportedOperationException If {@link MountCapability#MOUNT_FLAGS} is not supported
71+
* @see MountService#getDefaultMountFlags()
3372
*/
3473
@Contract("_ -> this")
3574
default MountBuilder setMountFlags(String mountFlags) {
3675
throw new UnsupportedOperationException();
3776
}
3877

78+
3979
/**
4080
* Instructs the mount to be read-only.
4181
*
4282
* @param mountReadOnly Whether to mount read-only.
4383
* @return <code>this</code>
44-
* @throws UnsupportedOperationException If {@link MountFeature#READ_ONLY} is not supported
84+
* @throws UnsupportedOperationException If {@link MountCapability#READ_ONLY} is not supported
4585
*/
4686
@Contract("_ -> this")
4787
default MountBuilder setReadOnly(boolean mountReadOnly) {
4888
throw new UnsupportedOperationException();
4989
}
5090

5191
/**
52-
* Use the given TCP port.
92+
* Sets a unique volume id.
93+
* <p>
94+
* The volume id is used as a path component, thus must conform with the os-dependent path component restrictions.
5395
*
54-
* @param port fixed TCP port or 0 to use a system-assigned port
96+
* @param volumeId String conforming with the os-dependent path component restrictions
5597
* @return <code>this</code>
56-
* @throws UnsupportedOperationException If {@link MountFeature#PORT} is not supported
98+
* @throws UnsupportedOperationException If {@link MountCapability#VOLUME_ID} is not supported
5799
*/
58100
@Contract("_ -> this")
59-
default MountBuilder setPort(@Range(from = 0, to = Short.MAX_VALUE) int port) {
101+
default MountBuilder setVolumeId(String volumeId) {
60102
throw new UnsupportedOperationException();
61103
}
62104

105+
/**
106+
* Sets a volume name.
107+
* <p>
108+
* The volume name is intended to be human-readable. The input string might be altered to replace non-conforming characters and thus is not suited to identify the volume.
109+
*
110+
* @param volumeName String conforming with the os-dependent naming restrictions
111+
* @return <code>this</code>
112+
* @throws UnsupportedOperationException If {@link MountCapability#VOLUME_NAME} is not supported
113+
*/
114+
@Contract("_ -> this")
115+
default MountBuilder setVolumeName(String volumeName) {
116+
throw new UnsupportedOperationException();
117+
}
63118

64119
/**
65120
* Mounts the file system.

src/main/java/org/cryptomator/integrations/mount/MountFeature.java renamed to src/main/java/org/cryptomator/integrations/mount/MountCapability.java

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,31 @@
11
package org.cryptomator.integrations.mount;
22

3+
import java.nio.file.Path;
4+
35
/**
46
* Describes what aspects of the mount implementation can or should be used.
57
* <p>
68
* This may be used to show or hide different configuration options depending on the chosen mount provider.
79
*/
8-
public enum MountFeature {
10+
public enum MountCapability {
11+
/**
12+
* The builder supports {@link MountBuilder#setFileSystemName(String)}.
13+
*/
14+
FILE_SYSTEM_NAME,
15+
16+
/**
17+
* The builder supports {@link MountBuilder#setLoopbackHostName(String)}.
18+
*/
19+
LOOPBACK_HOST_NAME,
20+
921
/**
10-
* The provider supports {@link MountProvider#getDefaultMountFlags(String)}
22+
* The service provider supports {@link MountService#getDefaultLoopbackPort()}
23+
* and the builder requires {@link MountBuilder#setLoopbackPort(int)}.
24+
*/
25+
LOOPBACK_PORT,
26+
27+
/**
28+
* The service provider supports {@link MountService#getDefaultMountFlags()}
1129
* and the builder requires {@link MountBuilder#setMountFlags(String)}.
1230
*/
1331
MOUNT_FLAGS,
@@ -17,7 +35,7 @@ public enum MountFeature {
1735
* <p>
1836
* This option is mutually exclusive with {@link #MOUNT_WITHIN_EXISTING_PARENT}.
1937
*
20-
* @see #DEFAULT_MOUNT_POINT
38+
* @see #MOUNT_TO_SYSTEM_CHOSEN_PATH
2139
*/
2240
MOUNT_TO_EXISTING_DIR,
2341

@@ -27,7 +45,7 @@ public enum MountFeature {
2745
* <p>
2846
* This option is mutually exclusive with {@link #MOUNT_TO_EXISTING_DIR}.
2947
*
30-
* @see #DEFAULT_MOUNT_POINT
48+
* @see #MOUNT_TO_SYSTEM_CHOSEN_PATH
3149
*/
3250
MOUNT_WITHIN_EXISTING_PARENT,
3351

@@ -36,18 +54,17 @@ public enum MountFeature {
3654
*
3755
* @see #MOUNT_TO_EXISTING_DIR
3856
* @see #MOUNT_WITHIN_EXISTING_PARENT
57+
* @see #MOUNT_TO_SYSTEM_CHOSEN_PATH
3958
*/
4059
MOUNT_AS_DRIVE_LETTER,
4160

4261
/**
43-
* The provider supports suggesting a default mount point via {@link MountProvider#getDefaultMountPoint(String)}.
44-
* <p>
45-
* The default mount point is guaranteed to be supported by the mount builder, regardless of its normal restrictions.
62+
* The service provider supports suggesting a default mount point, if no mount point is set via {@link MountBuilder#setMountpoint(Path)}.
4663
*/
47-
DEFAULT_MOUNT_POINT,
64+
MOUNT_TO_SYSTEM_CHOSEN_PATH,
4865

4966
/**
50-
* The builder supports {@link MountBuilder#setReadOnly(boolean)}
67+
* The builder supports {@link MountBuilder#setReadOnly(boolean)}.
5168
*/
5269
READ_ONLY,
5370

@@ -57,8 +74,12 @@ public enum MountFeature {
5774
UNMOUNT_FORCED,
5875

5976
/**
60-
* The provider supports {@link MountProvider#getDefaultPort()}
61-
* and the builder requires {@link MountBuilder#setPort(int)}.
77+
* The builder requires {@link MountBuilder#setVolumeId(String)}.
78+
*/
79+
VOLUME_ID,
80+
81+
/**
82+
* The builder supports {@link MountBuilder#setVolumeName(String)}.
6283
*/
63-
PORT
84+
VOLUME_NAME
6485
}

src/main/java/org/cryptomator/integrations/mount/MountProvider.java renamed to src/main/java/org/cryptomator/integrations/mount/MountService.java

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import org.cryptomator.integrations.common.IntegrationsLoader;
44
import org.jetbrains.annotations.Contract;
5-
import org.jetbrains.annotations.NotNull;
65
import org.jetbrains.annotations.Range;
76

87
import java.nio.file.Path;
@@ -14,15 +13,15 @@
1413
*
1514
* @since 1.2.0
1615
*/
17-
public interface MountProvider {
16+
public interface MountService {
1817

1918
/**
2019
* Loads all supported mount providers.
2120
*
2221
* @return Stream of supported MountProviders (may be empty)
2322
*/
24-
static Stream<MountProvider> get() {
25-
return IntegrationsLoader.loadAll(MountProvider.class).filter(MountProvider::isSupported);
23+
static Stream<MountService> get() {
24+
return IntegrationsLoader.loadAll(MountService.class).filter(MountService::isSupported);
2625
}
2726

2827
/**
@@ -40,49 +39,43 @@ static Stream<MountProvider> get() {
4039
*/
4140
boolean isSupported();
4241

43-
/**
44-
* A suitable mount point suggested by this provider.
45-
* <p>
46-
* Other than caller-provided mount points, the mount point suggested by this method can be
47-
* passed to {@link MountBuilder#setMountpoint(Path)} and is guaranteed to fulfill the builder's requirements
48-
* without further ado.
49-
*
50-
* @param mountPointSuffix String used in the generation of a mount point.
51-
* @return A path to a possible mount point.
52-
* @throws UnsupportedOperationException If {@link MountFeature#DEFAULT_MOUNT_POINT} is not supported
53-
*/
54-
default Path getDefaultMountPoint(String mountPointSuffix) {
55-
throw new UnsupportedOperationException();
56-
}
57-
5842
/**
5943
* Default mount flags. May be empty.
6044
*
61-
* @param mountName Name of the mount in the OS
6245
* @return Concatenated String of valid mount flags
63-
* @throws UnsupportedOperationException If {@link MountFeature#MOUNT_FLAGS} is not supported
46+
* @throws UnsupportedOperationException If {@link MountCapability#MOUNT_FLAGS} is not supported
6447
*/
65-
default String getDefaultMountFlags(String mountName) {
48+
default String getDefaultMountFlags() {
6649
throw new UnsupportedOperationException();
6750
}
6851

6952
/**
70-
* The default TCP port used by this provider.
53+
* The default TCP port of the loopback address used by this provider.
7154
*
7255
* @return fixed TCP port or 0 to use a system-assigned port
73-
* @throws UnsupportedOperationException If {@link MountFeature#PORT} is not supported
56+
* @throws UnsupportedOperationException If {@link MountCapability#LOOPBACK_PORT} is not supported
7457
*/
7558
@Range(from = 0, to = Short.MAX_VALUE)
76-
default int getDefaultPort() {
59+
default int getDefaultLoopbackPort() {
7760
throw new UnsupportedOperationException();
7861
}
7962

8063
/**
81-
* Mount features supported by this provider.
64+
* Mount capabilites supported by this provider.
8265
*
83-
* @return Set of supported {@link MountFeature}s
66+
* @return Set of supported {@link MountCapability}s
8467
*/
85-
Set<MountFeature> supportedFeatures();
68+
Set<MountCapability> capabilities();
69+
70+
/**
71+
* Tests whether this provider supports the given capability.
72+
*
73+
* @param capability The capability
74+
* @return {@code true} if supported
75+
*/
76+
default boolean hasCapability(MountCapability capability) {
77+
return capabilities().contains(capability);
78+
}
8679

8780

8881
/**

0 commit comments

Comments
 (0)