From 3108a43f049099e82926d90312e761e214e31cad Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Mon, 10 Jun 2024 09:01:56 +0200 Subject: [PATCH 1/9] draft --- pom.xml | 2 +- src/main/java/module-info.java | 3 +++ .../filemanagersidebar/SidebarService.java | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 src/main/java/org/cryptomator/integrations/filemanagersidebar/SidebarService.java diff --git a/pom.xml b/pom.xml index 44b0fa7..c05dc9a 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 org.cryptomator integrations-api - 1.4.0-SNAPSHOT + 1.4.0-sidebar Cryptomator Integrations API Defines optional service interfaces that may be used by Cryptomator diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index 7108775..f0221cf 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -1,3 +1,4 @@ +import org.cryptomator.integrations.filemanagersidebar.SidebarService; import org.cryptomator.integrations.mount.MountService; import org.cryptomator.integrations.revealpath.RevealPathService; import org.cryptomator.integrations.tray.TrayMenuController; @@ -18,6 +19,7 @@ exports org.cryptomator.integrations.revealpath; exports org.cryptomator.integrations.tray; exports org.cryptomator.integrations.uiappearance; + exports org.cryptomator.integrations.filemanagersidebar; uses AutoStartProvider; uses KeychainAccessProvider; @@ -26,4 +28,5 @@ uses TrayIntegrationProvider; uses TrayMenuController; uses UiAppearanceProvider; + uses SidebarService; } \ No newline at end of file diff --git a/src/main/java/org/cryptomator/integrations/filemanagersidebar/SidebarService.java b/src/main/java/org/cryptomator/integrations/filemanagersidebar/SidebarService.java new file mode 100644 index 0000000..55e621d --- /dev/null +++ b/src/main/java/org/cryptomator/integrations/filemanagersidebar/SidebarService.java @@ -0,0 +1,18 @@ +package org.cryptomator.integrations.filemanagersidebar; + +import org.cryptomator.integrations.common.IntegrationsLoader; + +import java.util.Optional; + +public interface SidebarService { + + SidebarEntry add(); + + interface SidebarEntry { + void remove(); + } + + static Optional get() { + return IntegrationsLoader.load(SidebarService.class); + } +} From 82d9342f1b3c51619f135db158cb51c86139e4ca Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Fri, 14 Jun 2024 18:00:23 +0200 Subject: [PATCH 2/9] change parameter to be the mountpoint path --- .../integrations/filemanagersidebar/SidebarService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/cryptomator/integrations/filemanagersidebar/SidebarService.java b/src/main/java/org/cryptomator/integrations/filemanagersidebar/SidebarService.java index 55e621d..f80bb95 100644 --- a/src/main/java/org/cryptomator/integrations/filemanagersidebar/SidebarService.java +++ b/src/main/java/org/cryptomator/integrations/filemanagersidebar/SidebarService.java @@ -2,11 +2,12 @@ import org.cryptomator.integrations.common.IntegrationsLoader; +import java.nio.file.Path; import java.util.Optional; public interface SidebarService { - SidebarEntry add(); + SidebarEntry add(Path mountpoint); interface SidebarEntry { void remove(); From 957fdcb18ab6c3a51d5dc46b193dccc319e14a32 Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Tue, 18 Jun 2024 11:36:55 +0200 Subject: [PATCH 3/9] Adjust SidebarService: * add doc * extend "add" method with displayName parameter * add service specific exception --- .../filemanagersidebar/SidebarService.java | 29 +++++++++++++++++-- .../SidebarServiceException.java | 4 +++ 2 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 src/main/java/org/cryptomator/integrations/filemanagersidebar/SidebarServiceException.java diff --git a/src/main/java/org/cryptomator/integrations/filemanagersidebar/SidebarService.java b/src/main/java/org/cryptomator/integrations/filemanagersidebar/SidebarService.java index f80bb95..dfda8f1 100644 --- a/src/main/java/org/cryptomator/integrations/filemanagersidebar/SidebarService.java +++ b/src/main/java/org/cryptomator/integrations/filemanagersidebar/SidebarService.java @@ -1,16 +1,39 @@ package org.cryptomator.integrations.filemanagersidebar; import org.cryptomator.integrations.common.IntegrationsLoader; +import org.jetbrains.annotations.NotNull; +import java.io.Closeable; import java.nio.file.Path; import java.util.Optional; +/** + * Service for integrating a given path into the sidebar/quick access bar of a filemanager. + */ public interface SidebarService { - SidebarEntry add(Path mountpoint); + /** + * Creates an entry in the filemanager sidebar. + * + * @param displayName The display name of the sidebar entry + * @param target The filesystem path the sidebar entry points to. + * @return a @{link SidebarEntry } object + */ + SidebarEntry add(@NotNull String displayName, @NotNull Path target) throws SidebarServiceException; - interface SidebarEntry { - void remove(); + /** + * An entry of the filemanager sidebar, created with this service. + */ + interface SidebarEntry extends Closeable { + + /** + * Removes this entry from the sidebar. Once removed, this object cannot be added again. + */ + void remove() throws SidebarServiceException; + + default void close() { + remove(); + } } static Optional get() { diff --git a/src/main/java/org/cryptomator/integrations/filemanagersidebar/SidebarServiceException.java b/src/main/java/org/cryptomator/integrations/filemanagersidebar/SidebarServiceException.java new file mode 100644 index 0000000..e341f13 --- /dev/null +++ b/src/main/java/org/cryptomator/integrations/filemanagersidebar/SidebarServiceException.java @@ -0,0 +1,4 @@ +package org.cryptomator.integrations.filemanagersidebar; + +public class SidebarServiceException extends RuntimeException { +} From c96ecebe0f03f87ad0c3f38526f5419ae73a2134 Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Tue, 18 Jun 2024 17:33:49 +0200 Subject: [PATCH 4/9] changing API * sidebar entries do not have be closable * make sidebarService exception checked --- .../filemanagersidebar/SidebarService.java | 14 ++++++-------- .../SidebarServiceException.java | 10 +++++++++- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/cryptomator/integrations/filemanagersidebar/SidebarService.java b/src/main/java/org/cryptomator/integrations/filemanagersidebar/SidebarService.java index dfda8f1..96424bb 100644 --- a/src/main/java/org/cryptomator/integrations/filemanagersidebar/SidebarService.java +++ b/src/main/java/org/cryptomator/integrations/filemanagersidebar/SidebarService.java @@ -17,23 +17,21 @@ public interface SidebarService { * * @param displayName The display name of the sidebar entry * @param target The filesystem path the sidebar entry points to. - * @return a @{link SidebarEntry } object + * @return a @{link SidebarEntry } object, used to remove the entry again + * @apiNote Depending on the implemenation, the display name may not be used. */ - SidebarEntry add(@NotNull String displayName, @NotNull Path target) throws SidebarServiceException; + SidebarEntry add(@NotNull Path target, @NotNull String displayName) throws SidebarServiceException; /** - * An entry of the filemanager sidebar, created with this service. + * An entry of the filemanager sidebar, created by an implementation of this service. */ - interface SidebarEntry extends Closeable { + interface SidebarEntry { /** * Removes this entry from the sidebar. Once removed, this object cannot be added again. */ - void remove() throws SidebarServiceException; + void remove(); - default void close() { - remove(); - } } static Optional get() { diff --git a/src/main/java/org/cryptomator/integrations/filemanagersidebar/SidebarServiceException.java b/src/main/java/org/cryptomator/integrations/filemanagersidebar/SidebarServiceException.java index e341f13..b3b1953 100644 --- a/src/main/java/org/cryptomator/integrations/filemanagersidebar/SidebarServiceException.java +++ b/src/main/java/org/cryptomator/integrations/filemanagersidebar/SidebarServiceException.java @@ -1,4 +1,12 @@ package org.cryptomator.integrations.filemanagersidebar; -public class SidebarServiceException extends RuntimeException { +public class SidebarServiceException extends Exception { + + public SidebarServiceException(String message) { + super(message); + } + + public SidebarServiceException(String message, Throwable t) { + super(message, t); + } } From 3d94f24ddff4dc177a6d93954f10efb0850b566e Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Wed, 19 Jun 2024 12:35:12 +0200 Subject: [PATCH 5/9] refined API --- src/main/java/module-info.java | 4 ++-- .../SidebarService.java | 20 ++++++++++++------- .../SidebarServiceException.java | 2 +- 3 files changed, 16 insertions(+), 10 deletions(-) rename src/main/java/org/cryptomator/integrations/{filemanagersidebar => sidebar}/SidebarService.java (53%) rename src/main/java/org/cryptomator/integrations/{filemanagersidebar => sidebar}/SidebarServiceException.java (79%) diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index f0221cf..25aadf1 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -1,4 +1,4 @@ -import org.cryptomator.integrations.filemanagersidebar.SidebarService; +import org.cryptomator.integrations.sidebar.SidebarService; import org.cryptomator.integrations.mount.MountService; import org.cryptomator.integrations.revealpath.RevealPathService; import org.cryptomator.integrations.tray.TrayMenuController; @@ -19,7 +19,7 @@ exports org.cryptomator.integrations.revealpath; exports org.cryptomator.integrations.tray; exports org.cryptomator.integrations.uiappearance; - exports org.cryptomator.integrations.filemanagersidebar; + exports org.cryptomator.integrations.sidebar; uses AutoStartProvider; uses KeychainAccessProvider; diff --git a/src/main/java/org/cryptomator/integrations/filemanagersidebar/SidebarService.java b/src/main/java/org/cryptomator/integrations/sidebar/SidebarService.java similarity index 53% rename from src/main/java/org/cryptomator/integrations/filemanagersidebar/SidebarService.java rename to src/main/java/org/cryptomator/integrations/sidebar/SidebarService.java index 96424bb..eb1c279 100644 --- a/src/main/java/org/cryptomator/integrations/filemanagersidebar/SidebarService.java +++ b/src/main/java/org/cryptomator/integrations/sidebar/SidebarService.java @@ -1,9 +1,9 @@ -package org.cryptomator.integrations.filemanagersidebar; +package org.cryptomator.integrations.sidebar; import org.cryptomator.integrations.common.IntegrationsLoader; +import org.jetbrains.annotations.Blocking; import org.jetbrains.annotations.NotNull; -import java.io.Closeable; import java.nio.file.Path; import java.util.Optional; @@ -15,11 +15,13 @@ public interface SidebarService { /** * Creates an entry in the filemanager sidebar. * + * @param target The filesystem path the sidebar entry points to * @param displayName The display name of the sidebar entry - * @param target The filesystem path the sidebar entry points to. - * @return a @{link SidebarEntry } object, used to remove the entry again - * @apiNote Depending on the implemenation, the display name may not be used. + * @return a {@link SidebarEntry }, used to remove the entry again + * @throws SidebarServiceException if adding an entry to the filemanager sidebar fails + * @apiNote It depends on the service implementation wether the display name is used or not. */ + @Blocking SidebarEntry add(@NotNull Path target, @NotNull String displayName) throws SidebarServiceException; /** @@ -28,9 +30,13 @@ public interface SidebarService { interface SidebarEntry { /** - * Removes this entry from the sidebar. Once removed, this object cannot be added again. + * Removes this entry from the sidebar. + * + * @throws SidebarServiceException if removal fails. + * @implSpec ServiceProviders should make this function idempotent, i.e. after the method is called once and succeeded, consecutive calls should not change anything or throw an error. */ - void remove(); + @Blocking + void remove() throws SidebarServiceException; } diff --git a/src/main/java/org/cryptomator/integrations/filemanagersidebar/SidebarServiceException.java b/src/main/java/org/cryptomator/integrations/sidebar/SidebarServiceException.java similarity index 79% rename from src/main/java/org/cryptomator/integrations/filemanagersidebar/SidebarServiceException.java rename to src/main/java/org/cryptomator/integrations/sidebar/SidebarServiceException.java index b3b1953..e78f825 100644 --- a/src/main/java/org/cryptomator/integrations/filemanagersidebar/SidebarServiceException.java +++ b/src/main/java/org/cryptomator/integrations/sidebar/SidebarServiceException.java @@ -1,4 +1,4 @@ -package org.cryptomator.integrations.filemanagersidebar; +package org.cryptomator.integrations.sidebar; public class SidebarServiceException extends Exception { From 6a7f9641bbcf844b18d92fc886ee59076d211ad4 Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Thu, 20 Jun 2024 16:51:15 +0200 Subject: [PATCH 6/9] change interface to return a list of sidebar service impls --- .../integrations/sidebar/SidebarService.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/cryptomator/integrations/sidebar/SidebarService.java b/src/main/java/org/cryptomator/integrations/sidebar/SidebarService.java index eb1c279..749b1cb 100644 --- a/src/main/java/org/cryptomator/integrations/sidebar/SidebarService.java +++ b/src/main/java/org/cryptomator/integrations/sidebar/SidebarService.java @@ -5,7 +5,7 @@ import org.jetbrains.annotations.NotNull; import java.nio.file.Path; -import java.util.Optional; +import java.util.stream.Stream; /** * Service for integrating a given path into the sidebar/quick access bar of a filemanager. @@ -40,7 +40,12 @@ interface SidebarEntry { } - static Optional get() { - return IntegrationsLoader.load(SidebarService.class); + /** + * Loads all supported mount providers. + * + * @return Stream of supported MountProviders (may be empty) + */ + static Stream get() { + return IntegrationsLoader.loadAll(SidebarService.class); } } From 6340bdb6f5600bdc3b486e2d9973ed3416882bad Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Thu, 20 Jun 2024 17:22:15 +0200 Subject: [PATCH 7/9] rename API to quickAccess --- pom.xml | 2 +- src/main/java/module-info.java | 6 +-- .../quickaccess/QuickAccessService.java | 53 +++++++++++++++++++ .../QuickAccessServiceException.java | 12 +++++ .../integrations/sidebar/SidebarService.java | 51 ------------------ .../sidebar/SidebarServiceException.java | 12 ----- 6 files changed, 69 insertions(+), 67 deletions(-) create mode 100644 src/main/java/org/cryptomator/integrations/quickaccess/QuickAccessService.java create mode 100644 src/main/java/org/cryptomator/integrations/quickaccess/QuickAccessServiceException.java delete mode 100644 src/main/java/org/cryptomator/integrations/sidebar/SidebarService.java delete mode 100644 src/main/java/org/cryptomator/integrations/sidebar/SidebarServiceException.java diff --git a/pom.xml b/pom.xml index c05dc9a..20a7b44 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 org.cryptomator integrations-api - 1.4.0-sidebar + 1.4.0-quickaccess Cryptomator Integrations API Defines optional service interfaces that may be used by Cryptomator diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index 25aadf1..9925772 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -1,4 +1,4 @@ -import org.cryptomator.integrations.sidebar.SidebarService; +import org.cryptomator.integrations.quickaccess.QuickAccessService; import org.cryptomator.integrations.mount.MountService; import org.cryptomator.integrations.revealpath.RevealPathService; import org.cryptomator.integrations.tray.TrayMenuController; @@ -19,7 +19,7 @@ exports org.cryptomator.integrations.revealpath; exports org.cryptomator.integrations.tray; exports org.cryptomator.integrations.uiappearance; - exports org.cryptomator.integrations.sidebar; + exports org.cryptomator.integrations.quickaccess; uses AutoStartProvider; uses KeychainAccessProvider; @@ -28,5 +28,5 @@ uses TrayIntegrationProvider; uses TrayMenuController; uses UiAppearanceProvider; - uses SidebarService; + uses QuickAccessService; } \ No newline at end of file diff --git a/src/main/java/org/cryptomator/integrations/quickaccess/QuickAccessService.java b/src/main/java/org/cryptomator/integrations/quickaccess/QuickAccessService.java new file mode 100644 index 0000000..3970983 --- /dev/null +++ b/src/main/java/org/cryptomator/integrations/quickaccess/QuickAccessService.java @@ -0,0 +1,53 @@ +package org.cryptomator.integrations.quickaccess; + +import org.cryptomator.integrations.common.IntegrationsLoader; +import org.jetbrains.annotations.Blocking; +import org.jetbrains.annotations.NotNull; + +import java.nio.file.Path; +import java.util.stream.Stream; + +/** + * Service adding a system path link to a quick access area of the OS or an application (e.g. file manager). + * + * @apiNote On purpose this service does not define, what an "link to a quick access area" is. The defintion depends on the OS. For example, the quick access area can be the home screen/desktop and the link would be an icon leading to the linked path. + */ +public interface QuickAccessService { + + /** + * Creates an entry in the quick access area. + * + * @param target The filesystem path the quick access entry points to + * @param displayName The display name of the quick access entry + * @return a {@link QuickAccessEntry }, used to remove the entry again + * @throws QuickAccessServiceException if adding an entry to the quick access area fails + * @apiNote It depends on the service implementation wether the display name is used or not. + */ + @Blocking + QuickAccessEntry add(@NotNull Path target, @NotNull String displayName) throws QuickAccessServiceException; + + /** + * An entry of the quick access area, created by a service implementation. + */ + interface QuickAccessEntry { + + /** + * Removes this entry from the quick access area. + * + * @throws QuickAccessServiceException if removal fails. + * @implSpec Service implementations should make this function idempotent, i.e. after the method is called once and succeeded, consecutive calls should not change anything or throw an error. + */ + @Blocking + void remove() throws QuickAccessServiceException; + + } + + /** + * Loads all supported service providers. + * + * @return Stream of supported {@link QuickAccessService} implementations (may be empty) + */ + static Stream get() { + return IntegrationsLoader.loadAll(QuickAccessService.class); + } +} diff --git a/src/main/java/org/cryptomator/integrations/quickaccess/QuickAccessServiceException.java b/src/main/java/org/cryptomator/integrations/quickaccess/QuickAccessServiceException.java new file mode 100644 index 0000000..38612f0 --- /dev/null +++ b/src/main/java/org/cryptomator/integrations/quickaccess/QuickAccessServiceException.java @@ -0,0 +1,12 @@ +package org.cryptomator.integrations.quickaccess; + +public class QuickAccessServiceException extends Exception { + + public QuickAccessServiceException(String message) { + super(message); + } + + public QuickAccessServiceException(String message, Throwable t) { + super(message, t); + } +} diff --git a/src/main/java/org/cryptomator/integrations/sidebar/SidebarService.java b/src/main/java/org/cryptomator/integrations/sidebar/SidebarService.java deleted file mode 100644 index 749b1cb..0000000 --- a/src/main/java/org/cryptomator/integrations/sidebar/SidebarService.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.cryptomator.integrations.sidebar; - -import org.cryptomator.integrations.common.IntegrationsLoader; -import org.jetbrains.annotations.Blocking; -import org.jetbrains.annotations.NotNull; - -import java.nio.file.Path; -import java.util.stream.Stream; - -/** - * Service for integrating a given path into the sidebar/quick access bar of a filemanager. - */ -public interface SidebarService { - - /** - * Creates an entry in the filemanager sidebar. - * - * @param target The filesystem path the sidebar entry points to - * @param displayName The display name of the sidebar entry - * @return a {@link SidebarEntry }, used to remove the entry again - * @throws SidebarServiceException if adding an entry to the filemanager sidebar fails - * @apiNote It depends on the service implementation wether the display name is used or not. - */ - @Blocking - SidebarEntry add(@NotNull Path target, @NotNull String displayName) throws SidebarServiceException; - - /** - * An entry of the filemanager sidebar, created by an implementation of this service. - */ - interface SidebarEntry { - - /** - * Removes this entry from the sidebar. - * - * @throws SidebarServiceException if removal fails. - * @implSpec ServiceProviders should make this function idempotent, i.e. after the method is called once and succeeded, consecutive calls should not change anything or throw an error. - */ - @Blocking - void remove() throws SidebarServiceException; - - } - - /** - * Loads all supported mount providers. - * - * @return Stream of supported MountProviders (may be empty) - */ - static Stream get() { - return IntegrationsLoader.loadAll(SidebarService.class); - } -} diff --git a/src/main/java/org/cryptomator/integrations/sidebar/SidebarServiceException.java b/src/main/java/org/cryptomator/integrations/sidebar/SidebarServiceException.java deleted file mode 100644 index e78f825..0000000 --- a/src/main/java/org/cryptomator/integrations/sidebar/SidebarServiceException.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.cryptomator.integrations.sidebar; - -public class SidebarServiceException extends Exception { - - public SidebarServiceException(String message) { - super(message); - } - - public SidebarServiceException(String message, Throwable t) { - super(message, t); - } -} From 7c9e7a3e7dcc688f55d3bea7d5c8e38ae99062f1 Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Thu, 27 Jun 2024 11:43:16 +0200 Subject: [PATCH 8/9] Annotate with @FunctionalInterface Co-authored-by: Sebastian Stenzel --- .../integrations/quickaccess/QuickAccessService.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/org/cryptomator/integrations/quickaccess/QuickAccessService.java b/src/main/java/org/cryptomator/integrations/quickaccess/QuickAccessService.java index 3970983..cc6b1f3 100644 --- a/src/main/java/org/cryptomator/integrations/quickaccess/QuickAccessService.java +++ b/src/main/java/org/cryptomator/integrations/quickaccess/QuickAccessService.java @@ -12,6 +12,7 @@ * * @apiNote On purpose this service does not define, what an "link to a quick access area" is. The defintion depends on the OS. For example, the quick access area can be the home screen/desktop and the link would be an icon leading to the linked path. */ +@FunctionalInterface public interface QuickAccessService { /** @@ -29,6 +30,7 @@ public interface QuickAccessService { /** * An entry of the quick access area, created by a service implementation. */ + @FunctionalInterface interface QuickAccessEntry { /** From 6572fe466d9f5818ae35c00d9ed2f502baf203d0 Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Thu, 27 Jun 2024 11:45:58 +0200 Subject: [PATCH 9/9] prepare merge --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 20a7b44..44b0fa7 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 org.cryptomator integrations-api - 1.4.0-quickaccess + 1.4.0-SNAPSHOT Cryptomator Integrations API Defines optional service interfaces that may be used by Cryptomator