From 446ce5b1c828f65754115f683b2faed5fa614088 Mon Sep 17 00:00:00 2001 From: crschnick Date: Tue, 28 Jan 2025 15:09:09 +0000 Subject: [PATCH] Fixes --- .../io/xpipe/app/icon/SystemIconManager.java | 8 ++++++++ .../java/io/xpipe/app/icon/SystemIconSource.java | 16 ++++++++++++++++ .../java/io/xpipe/app/prefs/IconsCategory.java | 5 +++++ .../io/xpipe/app/prefs/TroubleshootCategory.java | 2 +- .../xpipe/app/terminal/ExternalTerminalType.java | 8 ++++---- .../java/io/xpipe/app/update/AppInstaller.java | 6 +++--- 6 files changed, 37 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/icon/SystemIconManager.java b/app/src/main/java/io/xpipe/app/icon/SystemIconManager.java index baaccc3c0..7c0a9bb5d 100644 --- a/app/src/main/java/io/xpipe/app/icon/SystemIconManager.java +++ b/app/src/main/java/io/xpipe/app/icon/SystemIconManager.java @@ -5,6 +5,7 @@ import io.xpipe.app.issue.ErrorEvent; import io.xpipe.app.prefs.AppPrefs; import io.xpipe.app.resources.AppImages; import io.xpipe.app.storage.DataStorage; +import io.xpipe.core.util.ValidationException; import java.nio.file.Files; import java.nio.file.Path; @@ -23,6 +24,13 @@ public class SystemIconManager { all.add(SystemIconSource.Directory.builder().path(DataStorage.get().getIconsDir()).id("custom").build()); all.add(SystemIconSource.GitRepository.builder().remote("https://github.com/selfhst/icons").id("selfhst").build()); for (var pref : prefs) { + try { + pref.checkComplete(); + } catch (ValidationException e) { + ErrorEvent.fromThrowable(e).omit().expected().handle(); + continue; + } + if (!all.contains(pref)) { all.add(pref); } diff --git a/app/src/main/java/io/xpipe/app/icon/SystemIconSource.java b/app/src/main/java/io/xpipe/app/icon/SystemIconSource.java index 0d8049087..f9d4d5177 100644 --- a/app/src/main/java/io/xpipe/app/icon/SystemIconSource.java +++ b/app/src/main/java/io/xpipe/app/icon/SystemIconSource.java @@ -6,8 +6,10 @@ import com.fasterxml.jackson.annotation.JsonTypeName; import io.xpipe.app.ext.ProcessControlProvider; import io.xpipe.app.util.DesktopHelper; import io.xpipe.app.util.Hyperlinks; +import io.xpipe.app.util.Validators; import io.xpipe.core.process.CommandBuilder; import io.xpipe.core.store.FileNames; +import io.xpipe.core.util.ValidationException; import lombok.Builder; import lombok.Value; import lombok.extern.jackson.Jacksonized; @@ -32,6 +34,12 @@ public interface SystemIconSource { Path path; String id; + @Override + public void checkComplete() throws ValidationException { + Validators.nonNull(path); + Validators.notEmpty(id); + } + @Override public void refresh() throws Exception { Files.createDirectories(path); @@ -73,6 +81,12 @@ public interface SystemIconSource { String remote; String id; + @Override + public void checkComplete() throws ValidationException { + Validators.notEmpty(remote); + Validators.notEmpty(id); + } + @Override public void refresh() throws Exception { try (var sc = ProcessControlProvider.get().createLocalProcessControl(true).start()) { @@ -111,6 +125,8 @@ public interface SystemIconSource { } } + void checkComplete() throws ValidationException; + void refresh() throws Exception; String getId(); diff --git a/app/src/main/java/io/xpipe/app/prefs/IconsCategory.java b/app/src/main/java/io/xpipe/app/prefs/IconsCategory.java index e4e0c615f..4bd0dbbd9 100644 --- a/app/src/main/java/io/xpipe/app/prefs/IconsCategory.java +++ b/app/src/main/java/io/xpipe/app/prefs/IconsCategory.java @@ -81,6 +81,11 @@ public class IconsCategory extends AppPrefsCategory { return; } + // Don't use the git sync repo itself ... + if (remote.get().equals(AppPrefs.get().storageGitRemote().get())) { + return; + } + var source = SystemIconSource.GitRepository.builder().remote(remote.get()).id(UUID.randomUUID().toString()).build(); if (!sources.contains(source)) { sources.add(source); diff --git a/app/src/main/java/io/xpipe/app/prefs/TroubleshootCategory.java b/app/src/main/java/io/xpipe/app/prefs/TroubleshootCategory.java index 515ba21f4..af6dfe480 100644 --- a/app/src/main/java/io/xpipe/app/prefs/TroubleshootCategory.java +++ b/app/src/main/java/io/xpipe/app/prefs/TroubleshootCategory.java @@ -60,7 +60,7 @@ public class TroubleshootCategory extends AppPrefsCategory { .toString(), XPipeInstallation.getDaemonDebugScriptPath(OsType.getLocal())); // We can't use the SSH bridge - var type = ExternalTerminalType.determineNonSshBridgeFallback( + var type = ExternalTerminalType.determineFallbackTerminalToOpen( AppPrefs.get().terminalType().getValue()); TerminalLauncher.openDirect( "XPipe Debug", diff --git a/app/src/main/java/io/xpipe/app/terminal/ExternalTerminalType.java b/app/src/main/java/io/xpipe/app/terminal/ExternalTerminalType.java index 525b134be..81522c910 100644 --- a/app/src/main/java/io/xpipe/app/terminal/ExternalTerminalType.java +++ b/app/src/main/java/io/xpipe/app/terminal/ExternalTerminalType.java @@ -57,21 +57,21 @@ public interface ExternalTerminalType extends PrefsChoiceValue { // } // }; - static ExternalTerminalType determineNonSshBridgeFallback(ExternalTerminalType type) { + static ExternalTerminalType determineFallbackTerminalToOpen(ExternalTerminalType type) { if (type == XSHELL || type == MOBAXTERM || type == SECURECRT) { return ProcessControlProvider.get().getEffectiveLocalDialect() == ShellDialects.CMD ? CMD : POWERSHELL; } - if (type != TERMIUS) { + if (type != TERMIUS && type instanceof WaveTerminalType) { return type; } switch (OsType.getLocal()) { case OsType.Linux linux -> { - // This should not be termius as all others take precedence + // This should not be termius or wave as all others take precedence var def = determineDefault(null); // If there's no other terminal available, use a fallback which won't work - return def != TERMIUS ? def : XTERM; + return def != TERMIUS && def != WaveTerminalType.WAVE_LINUX ? def : XTERM; } case OsType.MacOs macOs -> { return MACOS_TERMINAL; diff --git a/app/src/main/java/io/xpipe/app/update/AppInstaller.java b/app/src/main/java/io/xpipe/app/update/AppInstaller.java index eaa39d35b..577716bb9 100644 --- a/app/src/main/java/io/xpipe/app/update/AppInstaller.java +++ b/app/src/main/java/io/xpipe/app/update/AppInstaller.java @@ -181,7 +181,7 @@ public class AppInstaller { runAndClose(() -> { // We can't use the SSH bridge - var type = ExternalTerminalType.determineNonSshBridgeFallback( + var type = ExternalTerminalType.determineFallbackTerminalToOpen( AppPrefs.get().terminalType().getValue()); TerminalLauncher.openDirect("XPipe Updater", sc -> command, type); }); @@ -222,7 +222,7 @@ public class AppInstaller { runAndClose(() -> { // We can't use the SSH bridge - var type = ExternalTerminalType.determineNonSshBridgeFallback( + var type = ExternalTerminalType.determineFallbackTerminalToOpen( AppPrefs.get().terminalType().getValue()); TerminalLauncher.openDirect("XPipe Updater", sc -> command, type); }); @@ -263,7 +263,7 @@ public class AppInstaller { runAndClose(() -> { // We can't use the SSH bridge - var type = ExternalTerminalType.determineNonSshBridgeFallback( + var type = ExternalTerminalType.determineFallbackTerminalToOpen( AppPrefs.get().terminalType().getValue()); TerminalLauncher.openDirect("XPipe Updater", sc -> command, type); });