From 3d64443ed50c8b261d351a5e45a7b9122afaee4b Mon Sep 17 00:00:00 2001 From: crschnick Date: Sun, 7 Apr 2024 11:11:16 +0000 Subject: [PATCH] Rework --- .../app/browser/action/BrowserAction.java | 4 -- .../xpipe/app/core/AppExtensionManager.java | 21 +-------- .../main/java/io/xpipe/app/core/AppI18n.java | 4 ++ .../app/exchange/MessageExchangeImpls.java | 46 +++++++++++-------- .../java/io/xpipe/app/ext/ActionProvider.java | 4 -- .../io/xpipe/app/ext/DataStoreProviders.java | 26 ++++++++--- .../java/io/xpipe/app/ext/PrefsProvider.java | 4 -- .../java/io/xpipe/app/ext/ScanProvider.java | 4 -- .../io/xpipe/app/util/LicenseProvider.java | 4 -- app/src/main/java/module-info.java | 6 +-- .../io/xpipe/core/process/ShellDialects.java | 5 -- .../io/xpipe/core/util/ModuleLayerLoader.java | 11 ++--- lang/proc/strings/translations_en.properties | 2 + lang/proc/texts/sshForwardX11_en.md | 9 ++++ lang/proc/texts/sshInteraction_en.md | 5 ++ 15 files changed, 73 insertions(+), 82 deletions(-) create mode 100644 lang/proc/texts/sshForwardX11_en.md create mode 100644 lang/proc/texts/sshInteraction_en.md diff --git a/app/src/main/java/io/xpipe/app/browser/action/BrowserAction.java b/app/src/main/java/io/xpipe/app/browser/action/BrowserAction.java index f1536114b..e51ca1f9f 100644 --- a/app/src/main/java/io/xpipe/app/browser/action/BrowserAction.java +++ b/app/src/main/java/io/xpipe/app/browser/action/BrowserAction.java @@ -92,9 +92,5 @@ public interface BrowserAction { .toList()); } - @Override - public boolean prioritizeLoading() { - return false; - } } } diff --git a/app/src/main/java/io/xpipe/app/core/AppExtensionManager.java b/app/src/main/java/io/xpipe/app/core/AppExtensionManager.java index 0f9ebf347..8b58139a2 100644 --- a/app/src/main/java/io/xpipe/app/core/AppExtensionManager.java +++ b/app/src/main/java/io/xpipe/app/core/AppExtensionManager.java @@ -1,14 +1,9 @@ package io.xpipe.app.core; -import com.fasterxml.jackson.databind.jsontype.NamedType; -import io.xpipe.app.exchange.MessageExchangeImpls; -import io.xpipe.app.ext.DataStoreProvider; -import io.xpipe.app.ext.DataStoreProviders; import io.xpipe.app.ext.ExtensionException; import io.xpipe.app.issue.ErrorEvent; import io.xpipe.app.issue.TrackEvent; import io.xpipe.core.process.ProcessControlProvider; -import io.xpipe.core.util.JacksonMapper; import io.xpipe.core.util.ModuleHelper; import io.xpipe.core.util.ModuleLayerLoader; import io.xpipe.core.util.XPipeInstallation; @@ -53,24 +48,10 @@ public class AppExtensionManager { if (load) { try { - ModuleLayerLoader.loadAll(INSTANCE.extendedLayer, true, t -> { - ErrorEvent.fromThrowable(t).handle(); - }); ProcessControlProvider.init(INSTANCE.extendedLayer); - TrackEvent.info("Loading extension providers ..."); - DataStoreProviders.init(INSTANCE.extendedLayer); - for (DataStoreProvider p : DataStoreProviders.getAll()) { - TrackEvent.trace("Loaded data store provider " + p.getId()); - JacksonMapper.configure(objectMapper -> { - for (Class storeClass : p.getStoreClasses()) { - objectMapper.registerSubtypes(new NamedType(storeClass)); - } - }); - } - ModuleLayerLoader.loadAll(INSTANCE.extendedLayer, false, t -> { + ModuleLayerLoader.loadAll(INSTANCE.extendedLayer, t -> { ErrorEvent.fromThrowable(t).handle(); }); - MessageExchangeImpls.loadAll(); } catch (Throwable t) { throw new ExtensionException( "Service provider initialization failed. Is the installation data corrupt?", t); diff --git a/app/src/main/java/io/xpipe/app/core/AppI18n.java b/app/src/main/java/io/xpipe/app/core/AppI18n.java index 7b57fd37b..cfb3e4aa2 100644 --- a/app/src/main/java/io/xpipe/app/core/AppI18n.java +++ b/app/src/main/java/io/xpipe/app/core/AppI18n.java @@ -48,6 +48,10 @@ public class AppI18n { private final Property currentLanguage = new SimpleObjectProperty<>(); public static void init() throws Exception { + if (INSTANCE != null) { + return; + } + INSTANCE = new AppI18n(); INSTANCE.load(); } diff --git a/app/src/main/java/io/xpipe/app/exchange/MessageExchangeImpls.java b/app/src/main/java/io/xpipe/app/exchange/MessageExchangeImpls.java index b318e8069..3b113bfe0 100644 --- a/app/src/main/java/io/xpipe/app/exchange/MessageExchangeImpls.java +++ b/app/src/main/java/io/xpipe/app/exchange/MessageExchangeImpls.java @@ -3,6 +3,7 @@ package io.xpipe.app.exchange; import io.xpipe.beacon.RequestMessage; import io.xpipe.beacon.ResponseMessage; import io.xpipe.beacon.exchange.MessageExchanges; +import io.xpipe.core.util.ModuleLayerLoader; import java.util.List; import java.util.Optional; @@ -11,28 +12,33 @@ import java.util.stream.Collectors; public class MessageExchangeImpls { + public static class Loader implements ModuleLayerLoader { + + @Override + public void init(ModuleLayer layer) { + ALL = ServiceLoader.load(layer, MessageExchangeImpl.class).stream() + .map(s -> { + // TrackEvent.trace("init", "Loaded exchange implementation " + ex.getId()); + return (MessageExchangeImpl) s.get(); + }) + .collect(Collectors.toList()); + + ALL.forEach(messageExchange -> { + if (MessageExchanges.byId(messageExchange.getId()).isEmpty()) { + throw new AssertionError("Missing base exchange: " + messageExchange.getId()); + } + }); + + MessageExchanges.getAll().forEach(messageExchange -> { + if (MessageExchangeImpls.byId(messageExchange.getId()).isEmpty()) { + throw new AssertionError("Missing exchange implementation: " + messageExchange.getId()); + } + }); + } + } + private static List> ALL; - public static void loadAll() { - ALL = ServiceLoader.load(MessageExchangeImpl.class).stream() - .map(s -> { - // TrackEvent.trace("init", "Loaded exchange implementation " + ex.getId()); - return (MessageExchangeImpl) s.get(); - }) - .collect(Collectors.toList()); - - ALL.forEach(messageExchange -> { - if (MessageExchanges.byId(messageExchange.getId()).isEmpty()) { - throw new AssertionError("Missing base exchange: " + messageExchange.getId()); - } - }); - - MessageExchanges.getAll().forEach(messageExchange -> { - if (MessageExchangeImpls.byId(messageExchange.getId()).isEmpty()) { - throw new AssertionError("Missing exchange implementation: " + messageExchange.getId()); - } - }); - } @SuppressWarnings("unchecked") public static Optional> byId( diff --git a/app/src/main/java/io/xpipe/app/ext/ActionProvider.java b/app/src/main/java/io/xpipe/app/ext/ActionProvider.java index 187ee42b6..8fafc49ef 100644 --- a/app/src/main/java/io/xpipe/app/ext/ActionProvider.java +++ b/app/src/main/java/io/xpipe/app/ext/ActionProvider.java @@ -144,9 +144,5 @@ public interface ActionProvider { .toList()); } - @Override - public boolean prioritizeLoading() { - return false; - } } } diff --git a/app/src/main/java/io/xpipe/app/ext/DataStoreProviders.java b/app/src/main/java/io/xpipe/app/ext/DataStoreProviders.java index 7931ae3ef..de5a12349 100644 --- a/app/src/main/java/io/xpipe/app/ext/DataStoreProviders.java +++ b/app/src/main/java/io/xpipe/app/ext/DataStoreProviders.java @@ -1,7 +1,11 @@ package io.xpipe.app.ext; +import com.fasterxml.jackson.databind.jsontype.NamedType; import io.xpipe.app.issue.ErrorEvent; +import io.xpipe.app.issue.TrackEvent; import io.xpipe.core.store.DataStore; +import io.xpipe.core.util.JacksonMapper; +import io.xpipe.core.util.ModuleLayerLoader; import java.util.List; import java.util.Optional; @@ -10,13 +14,12 @@ import java.util.stream.Collectors; public class DataStoreProviders { - private static List ALL; + public static class Loader implements ModuleLayerLoader { - public static void init(ModuleLayer layer) { - if (ALL == null) { - ALL = ServiceLoader.load(layer, DataStoreProvider.class).stream() - .map(ServiceLoader.Provider::get) - .collect(Collectors.toList()); + @Override + public void init(ModuleLayer layer) { + TrackEvent.info("Loading extension providers ..."); + ALL = ServiceLoader.load(layer, DataStoreProvider.class).stream().map(ServiceLoader.Provider::get).collect(Collectors.toList()); ALL.removeIf(p -> { try { if (!p.init()) { @@ -30,9 +33,20 @@ public class DataStoreProviders { return true; } }); + + for (DataStoreProvider p : getAll()) { + TrackEvent.trace("Loaded data store provider " + p.getId()); + JacksonMapper.configure(objectMapper -> { + for (Class storeClass : p.getStoreClasses()) { + objectMapper.registerSubtypes(new NamedType(storeClass)); + } + }); + } } } + private static List ALL; + public static void postInit(ModuleLayer layer) { ALL.forEach(p -> { try { diff --git a/app/src/main/java/io/xpipe/app/ext/PrefsProvider.java b/app/src/main/java/io/xpipe/app/ext/PrefsProvider.java index b69d480fb..9dff06ccf 100644 --- a/app/src/main/java/io/xpipe/app/ext/PrefsProvider.java +++ b/app/src/main/java/io/xpipe/app/ext/PrefsProvider.java @@ -35,9 +35,5 @@ public abstract class PrefsProvider { .collect(Collectors.toList()); } - @Override - public boolean prioritizeLoading() { - return false; - } } } diff --git a/app/src/main/java/io/xpipe/app/ext/ScanProvider.java b/app/src/main/java/io/xpipe/app/ext/ScanProvider.java index 6a7670a8f..d7b811d09 100644 --- a/app/src/main/java/io/xpipe/app/ext/ScanProvider.java +++ b/app/src/main/java/io/xpipe/app/ext/ScanProvider.java @@ -63,9 +63,5 @@ public abstract class ScanProvider { .collect(Collectors.toList()); } - @Override - public boolean prioritizeLoading() { - return false; - } } } diff --git a/app/src/main/java/io/xpipe/app/util/LicenseProvider.java b/app/src/main/java/io/xpipe/app/util/LicenseProvider.java index 0e76b0a73..fe06efd5d 100644 --- a/app/src/main/java/io/xpipe/app/util/LicenseProvider.java +++ b/app/src/main/java/io/xpipe/app/util/LicenseProvider.java @@ -42,9 +42,5 @@ public abstract class LicenseProvider { .orElseThrow(() -> ExtensionException.corrupt("Missing license provider")); } - @Override - public boolean prioritizeLoading() { - return true; - } } } diff --git a/app/src/main/java/module-info.java b/app/src/main/java/module-info.java index 6824b40ad..26300e20f 100644 --- a/app/src/main/java/module-info.java +++ b/app/src/main/java/module-info.java @@ -3,10 +3,7 @@ import io.xpipe.app.browser.action.BrowserAction; import io.xpipe.app.core.AppLogs; import io.xpipe.app.exchange.*; import io.xpipe.app.exchange.cli.*; -import io.xpipe.app.ext.ActionProvider; -import io.xpipe.app.ext.DataStoreProvider; -import io.xpipe.app.ext.PrefsProvider; -import io.xpipe.app.ext.ScanProvider; +import io.xpipe.app.ext.*; import io.xpipe.app.issue.EventHandler; import io.xpipe.app.issue.EventHandlerImpl; import io.xpipe.app.storage.DataStateProviderImpl; @@ -120,6 +117,7 @@ open module io.xpipe.app { provides Module with StorageJacksonModule; provides ModuleLayerLoader with + MessageExchangeImpls.Loader, DataStoreProviders.Loader, ActionProvider.Loader, PrefsProvider.Loader, BrowserAction.Loader, diff --git a/core/src/main/java/io/xpipe/core/process/ShellDialects.java b/core/src/main/java/io/xpipe/core/process/ShellDialects.java index 407b92dd3..4a86cd51c 100644 --- a/core/src/main/java/io/xpipe/core/process/ShellDialects.java +++ b/core/src/main/java/io/xpipe/core/process/ShellDialects.java @@ -78,10 +78,5 @@ public class ShellDialects { RBASH = byId("rbash"); OVH_BASTION = byId("ovhBastion"); } - - @Override - public boolean prioritizeLoading() { - return true; - } } } diff --git a/core/src/main/java/io/xpipe/core/util/ModuleLayerLoader.java b/core/src/main/java/io/xpipe/core/util/ModuleLayerLoader.java index 9c80809af..11d86d7c0 100644 --- a/core/src/main/java/io/xpipe/core/util/ModuleLayerLoader.java +++ b/core/src/main/java/io/xpipe/core/util/ModuleLayerLoader.java @@ -6,14 +6,10 @@ import java.util.function.Consumer; public interface ModuleLayerLoader { static void loadAll( - ModuleLayer layer, boolean prioritization, Consumer errorHandler) { + ModuleLayer layer, Consumer errorHandler) { ServiceLoader.load(layer, ModuleLayerLoader.class).stream().forEach(moduleLayerLoaderProvider -> { var instance = moduleLayerLoaderProvider.get(); try { - if (instance.prioritizeLoading() != prioritization) { - return; - } - instance.init(layer); } catch (Throwable t) { errorHandler.accept(t); @@ -21,7 +17,8 @@ public interface ModuleLayerLoader { }); } - void init(ModuleLayer layer); + default void init(ModuleLayer layer) {} + + default void reset() {} - boolean prioritizeLoading(); } diff --git a/lang/proc/strings/translations_en.properties b/lang/proc/strings/translations_en.properties index 9222d8252..600180d74 100644 --- a/lang/proc/strings/translations_en.properties +++ b/lang/proc/strings/translations_en.properties @@ -204,6 +204,8 @@ commandShellTypeDescription=The shell to use for this command ssh.passwordDescription=The optional password to use when authenticating keyAuthentication=Key-based authentication keyAuthenticationDescription=The authentication method to use if key-based authentication is required. +dontInteractWithSystem=Don't interact with system (Pro) +dontInteractWithSystemDescription=Don't try to identify shell and operating system type customAgent=Custom agent identityAgent=Identity agent ssh.proxyDescription=The optional proxy host to use when establishing the SSH connection. Must have an ssh client installed. diff --git a/lang/proc/texts/sshForwardX11_en.md b/lang/proc/texts/sshForwardX11_en.md new file mode 100644 index 000000000..223e2b573 --- /dev/null +++ b/lang/proc/texts/sshForwardX11_en.md @@ -0,0 +1,9 @@ +## X11 Forwarding + +When this option is enabled, the SSH connection will be started with X11 forwarding set up. On Linux, this will usually work out of the box and does not require any setup. On macOS, you need an X11 server like [XQuartz](https://www.xquartz.org/) to be running on your local machine. + +### X11 on Windows + +XPipe allows you to use the WSL2 X11 capabilities for your SSH connection. The only thing you need for this is a [WSL2](https://learn.microsoft.com/en-us/windows/wsl/install) distribution installed on your local system. XPipe it will automatically choose a compatible installed distribution if possible, but you can also use another one in the settings menu. + +This means that you don't need to install a separate X11 server on Windows. However, if you are using one anyway, XPipe will detect that and use the currently running X11 server. diff --git a/lang/proc/texts/sshInteraction_en.md b/lang/proc/texts/sshInteraction_en.md new file mode 100644 index 000000000..8fb881a6c --- /dev/null +++ b/lang/proc/texts/sshInteraction_en.md @@ -0,0 +1,5 @@ +## System interaction + +XPipe tries to detect what kind of shell it logged into to verify that everything worked correctly and to display system information. That works for normal command shells like bash, but fails for non-standard and custom login shells for many embedded systems. You have to disable this behavior in order for connections to these systems to succeed. + +When this interaction is disabled, it will not attempt to identify any system information. This will prevent the system to be used in the file browser or as a proxy/gateway system for other connections. XPipe will then essentially just act as a launcher for the connection.