From e7180521dd99679692614d29b2ef53eaccfa8edf Mon Sep 17 00:00:00 2001 From: crschnick Date: Thu, 29 Jan 2026 10:14:46 +0000 Subject: [PATCH] Various fixes --- .../io/xpipe/app/icon/SystemIconManager.java | 20 +++-- .../app/pwman/KeeperPasswordManager.java | 82 ++----------------- .../app/terminal/WindowsTerminalType.java | 5 +- app/src/main/java/module-info.java | 1 - 4 files changed, 23 insertions(+), 85 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 0614abf6a..d490411a2 100644 --- a/app/src/main/java/io/xpipe/app/icon/SystemIconManager.java +++ b/app/src/main/java/io/xpipe/app/icon/SystemIconManager.java @@ -17,7 +17,7 @@ public class SystemIconManager { AppProperties.get().getDataDir().resolve("cache").resolve("icons").resolve("pool"); private static final Set loadedIconImages = new HashSet<>(); - private static final Map LOADED = new HashMap<>(); + private static final Map LOADED_SOURCES = new HashMap<>(); private static final Set ICONS = new HashSet<>(); private static int cacheSourceHash; private static int sourceHash; @@ -110,7 +110,7 @@ public class SystemIconManager { private static synchronized int calculateSourceHash() { var total = 0; var set = false; - for (var e : LOADED.entrySet()) { + for (var e : LOADED_SOURCES.entrySet()) { total += e.getKey().getPath().hashCode(); for (SystemIconSourceFile icon : e.getValue().getIcons()) { total += icon.getFile().toString().hashCode(); @@ -140,9 +140,9 @@ public class SystemIconManager { public static void initAdditional() { for (var source : getEffectiveSources()) { - if (!LOADED.containsKey(source)) { + if (!LOADED_SOURCES.containsKey(source)) { var data = SystemIconSourceData.of(source); - LOADED.put(source, data); + LOADED_SOURCES.put(source, data); data.getIcons().forEach(systemIconSourceFile -> { var icon = new SystemIcon(source, systemIconSourceFile.getName()); ICONS.add(icon); @@ -155,13 +155,13 @@ public class SystemIconManager { public static synchronized void reloadSources() throws Exception { Files.createDirectories(DIRECTORY); - LOADED.clear(); + LOADED_SOURCES.clear(); for (var source : getEffectiveSources()) { - LOADED.put(source, SystemIconSourceData.of(source)); + LOADED_SOURCES.put(source, SystemIconSourceData.of(source)); } ICONS.clear(); - LOADED.forEach((source, systemIconSourceData) -> { + LOADED_SOURCES.forEach((source, systemIconSourceData) -> { systemIconSourceData.getIcons().forEach(systemIconSourceFile -> { var icon = new SystemIcon(source, systemIconSourceFile.getName()); ICONS.add(icon); @@ -177,8 +177,10 @@ public class SystemIconManager { private static synchronized void reloadImages() { AppImages.remove(s -> s.startsWith("icons/")); + loadedIconImages.clear(); + try { - for (var loadedIconImage : loadedIconImages) { + for (var loadedIconImage : ICONS) { getAndLoadIconFile(loadedIconImage); } } catch (Exception e) { @@ -197,7 +199,7 @@ public class SystemIconManager { } reloadSources(); sourceHash = calculateSourceHash(); - SystemIconCache.rebuildCache(LOADED, sourceHash); + SystemIconCache.rebuildCache(LOADED_SOURCES, sourceHash); cacheSourceHash = sourceHash; reloadImages(); } diff --git a/app/src/main/java/io/xpipe/app/pwman/KeeperPasswordManager.java b/app/src/main/java/io/xpipe/app/pwman/KeeperPasswordManager.java index ea9b30590..87f03e6a4 100644 --- a/app/src/main/java/io/xpipe/app/pwman/KeeperPasswordManager.java +++ b/app/src/main/java/io/xpipe/app/pwman/KeeperPasswordManager.java @@ -128,9 +128,8 @@ public class KeeperPasswordManager implements PasswordManager { } var b = CommandBuilder.of() - .add(getExecutable(sc), "get") + .add(getExecutable(sc), "find-password") .addLiteral(key) - .add("--format", "json", "--unmask") .add("--password") .addLiteral(r.getSecretValue()); FilePath file = sc.getSystemTemporaryDirectory().join("keeper" + Math.abs(new Random().nextInt()) + ".txt"); @@ -176,9 +175,7 @@ public class KeeperPasswordManager implements PasswordManager { var result = queryCommand.readStdoutAndStderr(); var exitCode = queryCommand.getExitCode(); - if (file != null) { - // sc.view().deleteFileIfPossible(file); - } + sc.view().deleteFileIfPossible(file); var out = result[0] .replace("\r\n", "\n") @@ -200,21 +197,10 @@ public class KeeperPasswordManager implements PasswordManager { EOF when reading a line """, "").strip(); - var jsonStart = out.indexOf("{\n"); - var jsonEnd = out.indexOf("\n}"); - if (jsonEnd != -1) { - jsonEnd += 2; - } - - var outPrefix = jsonStart <= 0 ? out : out.substring(0, jsonStart); - var outJson = jsonStart <= 0 - ? (jsonEnd != -1 ? out.substring(0, jsonEnd) : out) - : (jsonEnd != -1 ? out.substring(jsonStart, jsonEnd) : out.substring(jsonStart)); - + var message = !err.isEmpty() ? out + "\n" + err : out; if (exitCode != 0) { // Another password prompt was made - var wrongPw = - outPrefix.contains("Enter password for") || exitCode == CommandControl.EXIT_TIMEOUT_EXIT_CODE; + var wrongPw = out.contains("Enter password for") || exitCode == CommandControl.EXIT_TIMEOUT_EXIT_CODE; if (wrongPw) { SecretManager.clearAll(KEEPER_PASSWORD_ID); ErrorEventFactory.fromMessage("Master password was not accepted by Keeper. Is it correct?") @@ -223,69 +209,19 @@ public class KeeperPasswordManager implements PasswordManager { return null; } - var message = !err.isEmpty() ? outPrefix + "\n" + err : outPrefix; - ErrorEventFactory.fromMessage(message).expected().handle(); - return null; - } - - JsonNode tree; - try { - tree = JacksonMapper.getDefault().readTree(outJson); - } catch (JsonProcessingException e) { - var message = !err.isEmpty() ? outPrefix + "\n" + err : outPrefix; ErrorEventFactory.fromMessage(message).expected().handle(); return null; } hasCompletedRequestInSession = true; - var fields = tree.get("fields"); - // There multiple schemas - if (fields == null || !fields.isArray()) { - String login = null; - String password = null; - - var l = tree.get("login"); - if (l != null && l.isTextual()) { - login = l.asText(); - } - - var p = tree.get("password"); - if (p != null && p.isTextual()) { - password = p.asText(); - } - - if (login == null && password == null) { - var message = !err.isEmpty() ? out + "\n" + err : out; - ErrorEventFactory.fromMessage(message) - .description("Received invalid response") - .expected() - .handle(); - return null; - } - - return new CredentialResult(login, password != null ? InPlaceSecretValue.of(password) : null); + var outLines = out.lines().toList(); + if (outLines.isEmpty()) { + return null; } - String login = null; - String password = null; - for (JsonNode field : fields) { - var type = field.required("type").asText(); - if (type.equals("login")) { - var v = field.required("value"); - if (v.size() > 0) { - login = v.get(0).asText(); - } - } - if (type.equals("password")) { - var v = field.required("value"); - if (v.size() > 0) { - password = v.get(0).asText(); - } - } - } - - return new CredentialResult(login, password != null ? InPlaceSecretValue.of(password) : null); + var lastLine = outLines.getLast(); + return new CredentialResult(null, InPlaceSecretValue.of(lastLine)); } catch (Exception ex) { ErrorEventFactory.fromThrowable(ex).handle(); return null; diff --git a/app/src/main/java/io/xpipe/app/terminal/WindowsTerminalType.java b/app/src/main/java/io/xpipe/app/terminal/WindowsTerminalType.java index cb24c3219..4b8e68e85 100644 --- a/app/src/main/java/io/xpipe/app/terminal/WindowsTerminalType.java +++ b/app/src/main/java/io/xpipe/app/terminal/WindowsTerminalType.java @@ -27,7 +27,7 @@ public interface WindowsTerminalType extends ExternalTerminalType, TrackableTerm ExternalTerminalType WINDOWS_TERMINAL_PREVIEW = new Preview(); ExternalTerminalType WINDOWS_TERMINAL_CANARY = new Canary(); - AtomicInteger windowCounter = new AtomicInteger(10); + AtomicInteger windowCounter = new AtomicInteger(101); private static String getFixedTitle(String s) { // A weird behavior in Windows Terminal causes the trailing @@ -40,8 +40,9 @@ public interface WindowsTerminalType extends ExternalTerminalType, TrackableTerm } private static CommandBuilder toCommand(TerminalLaunchConfiguration configuration) { + // Start from high window index to guarantee that xpipe uses its own window var cmd = CommandBuilder.of() - .addIf(configuration.isPreferTabs(), "-w", "1", "nt") + .addIf(configuration.isPreferTabs(), "-w", "100", "nt") .addIf(!configuration.isPreferTabs(), "-w", "" + windowCounter.getAndIncrement()); if (configuration.getColor() != null) { diff --git a/app/src/main/java/module-info.java b/app/src/main/java/module-info.java index 55f43e66b..f310696e6 100644 --- a/app/src/main/java/module-info.java +++ b/app/src/main/java/module-info.java @@ -110,7 +110,6 @@ open module io.xpipe.app { requires org.kordamp.ikonli.bootstrapicons; requires jdk.zipfs; requires org.int4.fx.builders; - requires io.xpipe.app; uses TerminalLauncher; uses ActionProvider;