From 6340bdb6f5600bdc3b486e2d9973ed3416882bad Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Thu, 20 Jun 2024 17:22:15 +0200 Subject: [PATCH] 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); - } -}