diff --git a/app/src/main/java/io/xpipe/app/comp/store/StoreCreationComp.java b/app/src/main/java/io/xpipe/app/comp/store/StoreCreationComp.java index 528fff92c..c2c97fbbf 100644 --- a/app/src/main/java/io/xpipe/app/comp/store/StoreCreationComp.java +++ b/app/src/main/java/io/xpipe/app/comp/store/StoreCreationComp.java @@ -197,7 +197,7 @@ public class StoreCreationComp extends DialogComp { try { DataStorage.get().addStoreEntryIfNotPresent(e); if (validated - && e.getProvider().shouldHaveChildren() + && e.getProvider().shouldShowScan() && AppPrefs.get() .openConnectionSearchWindowOnConnectionCreation() .get()) { diff --git a/app/src/main/java/io/xpipe/app/ext/DataStoreProvider.java b/app/src/main/java/io/xpipe/app/ext/DataStoreProvider.java index 4088ed0b2..cb1e01cd1 100644 --- a/app/src/main/java/io/xpipe/app/ext/DataStoreProvider.java +++ b/app/src/main/java/io/xpipe/app/ext/DataStoreProvider.java @@ -96,14 +96,10 @@ public interface DataStoreProvider { return new StoreSectionComp(section, topLevel); } - default boolean canHaveSubShells() { + default boolean shouldShowScan() { return true; } - default boolean shouldHaveChildren() { - return canHaveSubShells(); - } - default Comp stateDisplay(StoreEntryWrapper w) { return Comp.empty(); } diff --git a/app/src/main/java/io/xpipe/app/util/ScanAlert.java b/app/src/main/java/io/xpipe/app/util/ScanAlert.java index 0e0b4de39..1dfdac33c 100644 --- a/app/src/main/java/io/xpipe/app/util/ScanAlert.java +++ b/app/src/main/java/io/xpipe/app/util/ScanAlert.java @@ -49,6 +49,10 @@ public class ScanAlert { public static void showForShellStore(DataStoreEntry initial) { show(initial, (DataStoreEntry entry, ShellControl sc) -> { + if (!sc.canHaveSubshells()) { + return null; + } + if (!sc.getShellDialect().getDumbMode().supportsAnyPossibleInteraction()) { return null; } diff --git a/core/src/main/java/io/xpipe/core/process/ShellControl.java b/core/src/main/java/io/xpipe/core/process/ShellControl.java index 8ca6c946a..55197b0c5 100644 --- a/core/src/main/java/io/xpipe/core/process/ShellControl.java +++ b/core/src/main/java/io/xpipe/core/process/ShellControl.java @@ -46,6 +46,10 @@ public interface ShellControl extends ProcessControl { boolean isLocal(); + default boolean canHaveSubshells() { + return true; + } + ShellControl getMachineRootSession(); ShellControl withoutLicenseCheck(); diff --git a/core/src/main/java/io/xpipe/core/process/ShellDialect.java b/core/src/main/java/io/xpipe/core/process/ShellDialect.java index f286d90d2..23ae9b4a0 100644 --- a/core/src/main/java/io/xpipe/core/process/ShellDialect.java +++ b/core/src/main/java/io/xpipe/core/process/ShellDialect.java @@ -146,7 +146,11 @@ public interface ShellDialect { String getPrintWorkingDirectoryCommand(); - StreamCharset getScriptCharset(); + StreamCharset getTextCharset(); + + default StreamCharset getScriptCharset() { + return getTextCharset(); + } CommandControl getFileCopyCommand(ShellControl parent, String oldFile, String newFile); diff --git a/core/src/main/java/io/xpipe/core/util/StreamCharset.java b/core/src/main/java/io/xpipe/core/util/StreamCharset.java index 2a4b32b28..a0ec72f55 100644 --- a/core/src/main/java/io/xpipe/core/util/StreamCharset.java +++ b/core/src/main/java/io/xpipe/core/util/StreamCharset.java @@ -2,6 +2,7 @@ package io.xpipe.core.util; import lombok.Value; +import java.io.ByteArrayInputStream; import java.io.InputStream; import java.io.InputStreamReader; import java.nio.charset.Charset; @@ -158,6 +159,20 @@ public class StreamCharset { return detected.reader(inputStream); } + public String read(byte[] b) throws Exception { + return read(new ByteArrayInputStream(b)); + } + + public String read(InputStream inputStream) throws Exception { + if (hasByteOrderMark()) { + var bom = inputStream.readNBytes(getByteOrderMark().length); + if (bom.length != 0 && !Arrays.equals(bom, getByteOrderMark())) { + throw new IllegalStateException("Charset does not match: " + charset.toString()); + } + } + return new String(inputStream.readAllBytes(), charset); + } + public InputStreamReader reader(InputStream stream) throws Exception { if (hasByteOrderMark()) { var bom = stream.readNBytes(getByteOrderMark().length); diff --git a/ext/base/src/main/java/io/xpipe/ext/base/action/ScanStoreAction.java b/ext/base/src/main/java/io/xpipe/ext/base/action/ScanStoreAction.java index 8d3569c84..717335ded 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/action/ScanStoreAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/action/ScanStoreAction.java @@ -31,15 +31,11 @@ public class ScanStoreAction implements ActionProvider { @Override public boolean isMajor(DataStoreEntryRef o) { - return o.get().getProvider().shouldHaveChildren(); + return true; } @Override public boolean isApplicable(DataStoreEntryRef o) { - if (!o.get().getProvider().canHaveSubShells()) { - return false; - } - var state = o.get().getStorePersistentState(); if (state instanceof ShellStoreState shellStoreState) { return (shellStoreState.getShellDialect() == null diff --git a/ext/base/src/main/java/io/xpipe/ext/base/script/SimpleScriptStoreProvider.java b/ext/base/src/main/java/io/xpipe/ext/base/script/SimpleScriptStoreProvider.java index 54297995a..c04af1825 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/script/SimpleScriptStoreProvider.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/script/SimpleScriptStoreProvider.java @@ -46,7 +46,7 @@ public class SimpleScriptStoreProvider implements EnabledParentStoreProvider, Da } @Override - public boolean shouldHaveChildren() { + public boolean shouldShowScan() { return false; }