diff --git a/app/src/main/java/io/xpipe/app/storage/DataStorage.java b/app/src/main/java/io/xpipe/app/storage/DataStorage.java index fe583c5a..984a4e1d 100644 --- a/app/src/main/java/io/xpipe/app/storage/DataStorage.java +++ b/app/src/main/java/io/xpipe/app/storage/DataStorage.java @@ -1,6 +1,7 @@ package io.xpipe.app.storage; import io.xpipe.app.comp.store.StoreSortMode; +import io.xpipe.app.ext.DataStorageExtensionProvider; import io.xpipe.app.issue.ErrorEvent; import io.xpipe.app.prefs.AppPrefs; import io.xpipe.app.util.FixedHierarchyStore; @@ -552,7 +553,6 @@ public abstract class DataStorage { for (DataStoreEntry e : toAdd) { var syntheticParent = getSyntheticParent(e); if (syntheticParent.isPresent()) { - var exists = addStoreEntryIfNotPresent(syntheticParent.get()); } diff --git a/app/src/main/java/io/xpipe/app/util/LicenseConnectionLimit.java b/app/src/main/java/io/xpipe/app/util/LicenseConnectionLimit.java new file mode 100644 index 00000000..7210023a --- /dev/null +++ b/app/src/main/java/io/xpipe/app/util/LicenseConnectionLimit.java @@ -0,0 +1,32 @@ +package io.xpipe.app.util; + +import io.xpipe.app.storage.DataStorage; +import io.xpipe.core.store.DataStore; + +public abstract class LicenseConnectionLimit { + + private final int limit; + private final LicensedFeature feature; + + public LicenseConnectionLimit(int limit, LicensedFeature feature) { + this.limit = limit; + this.feature = feature; + } + + protected abstract boolean matches(DataStore store); + + public void checkLimit() { + if (feature.isSupported()) { + return; + } + + var found = DataStorage.get() + .getStoreEntries() + .stream() + .filter(entry -> entry.getValidity().isUsable() && matches(entry.getStore())) + .toList(); + if (found.size() > limit) { + throw new LicenseRequiredException(feature, limit); + } + } +} diff --git a/app/src/main/java/io/xpipe/app/util/LicenseRequiredException.java b/app/src/main/java/io/xpipe/app/util/LicenseRequiredException.java index 53bae986..2e117309 100644 --- a/app/src/main/java/io/xpipe/app/util/LicenseRequiredException.java +++ b/app/src/main/java/io/xpipe/app/util/LicenseRequiredException.java @@ -1,7 +1,6 @@ package io.xpipe.app.util; import io.xpipe.app.core.AppI18n; - import lombok.Getter; @Getter @@ -15,6 +14,12 @@ public class LicenseRequiredException extends RuntimeException { this.feature = feature; } + public LicenseRequiredException(LicensedFeature feature, int limit) { + super(feature.getDisplayName() + " " + + (feature.isPlural() ? AppI18n.get("areOnlySupportedLimit", limit) : AppI18n.get("isOnlySupportedLimit", limit))); + this.feature = feature; + } + public LicenseRequiredException(String featureName, boolean plural, LicensedFeature feature) { super(featureName + " " + (plural ? AppI18n.get("areOnlySupported") : AppI18n.get("isOnlySupported"))); this.feature = feature; diff --git a/app/src/main/java/io/xpipe/app/util/LocalShell.java b/app/src/main/java/io/xpipe/app/util/LocalShell.java index 18f8f49e..939ceaaa 100644 --- a/app/src/main/java/io/xpipe/app/util/LocalShell.java +++ b/app/src/main/java/io/xpipe/app/util/LocalShell.java @@ -41,6 +41,7 @@ public class LocalShell { localPowershell = ProcessControlProvider.get() .createLocalProcessControl(false) .subShell(ShellDialects.POWERSHELL) + .withoutLicenseCheck() .start(); } return localPowershell.start(); diff --git a/ext/base/src/main/java/module-info.java b/ext/base/src/main/java/module-info.java index ce92dbbe..29be2492 100644 --- a/ext/base/src/main/java/module-info.java +++ b/ext/base/src/main/java/module-info.java @@ -32,7 +32,6 @@ open module io.xpipe.ext.base { requires static io.xpipe.app; requires org.kordamp.ikonli.javafx; requires atlantafx.base; - requires jdk.jfr; provides BrowserAction with RunScriptAction, FollowLinkAction, diff --git a/lang/app/strings/translations_en.properties b/lang/app/strings/translations_en.properties index a3636c17..564d4883 100644 --- a/lang/app/strings/translations_en.properties +++ b/lang/app/strings/translations_en.properties @@ -475,3 +475,5 @@ importConnections=Sync connections importConnectionsTitle=Import Connections showAllChildren=Show all children httpApi=HTTP API +isOnlySupportedLimit=is only supported with a professional license when having more than $COUNT$ active connections +areOnlySupportedLimit=are only supported with a professional license when having more than $COUNT$ active connections