mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-08-26 11:16:29 +00:00
Rework open args
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package io.xpipe.app.beacon.impl;
|
||||
|
||||
import io.xpipe.app.core.launcher.LauncherInput;
|
||||
import io.xpipe.app.core.AppOpenArguments;
|
||||
import io.xpipe.app.core.mode.OperationMode;
|
||||
import io.xpipe.app.util.PlatformInit;
|
||||
import io.xpipe.beacon.BeaconServerException;
|
||||
@@ -20,7 +20,7 @@ public class DaemonOpenExchangeImpl extends DaemonOpenExchange {
|
||||
|
||||
OperationMode.switchToAsync(OperationMode.GUI);
|
||||
} else {
|
||||
LauncherInput.handle(msg.getArguments());
|
||||
AppOpenArguments.handle(msg.getArguments());
|
||||
}
|
||||
return Response.builder().build();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package io.xpipe.app.core;
|
||||
|
||||
import io.xpipe.app.core.launcher.LauncherInput;
|
||||
import io.xpipe.app.core.window.AppDialog;
|
||||
|
||||
import javafx.scene.input.Clipboard;
|
||||
@@ -25,7 +24,7 @@ public class AppActionLinkDetector {
|
||||
}
|
||||
|
||||
public static void handle(String content, boolean showAlert) {
|
||||
var detected = LauncherInput.of(content);
|
||||
var detected = AppOpenArguments.parseActions(content);
|
||||
if (detected.size() == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -34,7 +33,7 @@ public class AppActionLinkDetector {
|
||||
return;
|
||||
}
|
||||
|
||||
LauncherInput.handle(List.of(content));
|
||||
AppOpenArguments.handle(List.of(content));
|
||||
}
|
||||
|
||||
public static void detectOnFocus() {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package io.xpipe.app.core;
|
||||
|
||||
import io.xpipe.app.Main;
|
||||
import io.xpipe.app.core.launcher.LauncherInput;
|
||||
import io.xpipe.app.core.mode.OperationMode;
|
||||
import io.xpipe.app.issue.ErrorEvent;
|
||||
import io.xpipe.app.prefs.AppPrefs;
|
||||
@@ -58,7 +57,7 @@ public class AppDesktopIntegration {
|
||||
|
||||
// URL open operations have to be handled in a special way on macOS!
|
||||
Desktop.getDesktop().setOpenURIHandler(e -> {
|
||||
LauncherInput.handle(List.of(e.getURI().toString()));
|
||||
AppOpenArguments.handle(List.of(e.getURI().toString()));
|
||||
});
|
||||
|
||||
// Do it this way to prevent IDE inspections from complaining
|
||||
|
||||
+26
-7
@@ -1,12 +1,11 @@
|
||||
package io.xpipe.app.core.launcher;
|
||||
package io.xpipe.app.core;
|
||||
|
||||
import io.xpipe.app.browser.BrowserFullSessionModel;
|
||||
import io.xpipe.app.core.AppLayoutModel;
|
||||
import io.xpipe.app.core.mode.OperationMode;
|
||||
import io.xpipe.app.ext.ActionProvider;
|
||||
import io.xpipe.app.issue.ErrorEvent;
|
||||
import io.xpipe.app.issue.TrackEvent;
|
||||
import io.xpipe.app.storage.DataStorage;
|
||||
|
||||
import lombok.Value;
|
||||
|
||||
import java.net.URI;
|
||||
@@ -16,9 +15,29 @@ import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class LauncherInput {
|
||||
public class AppOpenArguments {
|
||||
|
||||
public static void handle(List<String> arguments) {
|
||||
private static final List<String> bufferedArguments = new ArrayList<>();
|
||||
|
||||
public static synchronized void init() {
|
||||
handleImpl(bufferedArguments);
|
||||
bufferedArguments.clear();
|
||||
}
|
||||
|
||||
public static synchronized void handle(List<String> arguments) {
|
||||
if (OperationMode.isInShutdown()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (OperationMode.isInStartup()) {
|
||||
bufferedArguments.addAll(arguments);
|
||||
return;
|
||||
}
|
||||
|
||||
handleImpl(arguments);
|
||||
}
|
||||
|
||||
private static synchronized void handleImpl(List<String> arguments) {
|
||||
if (arguments.size() == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -28,7 +47,7 @@ public abstract class LauncherInput {
|
||||
var all = new ArrayList<ActionProvider.Action>();
|
||||
arguments.forEach(s -> {
|
||||
try {
|
||||
all.addAll(of(s));
|
||||
all.addAll(parseActions(s));
|
||||
} catch (Exception e) {
|
||||
ErrorEvent.fromThrowable(e).omit().handle();
|
||||
}
|
||||
@@ -49,7 +68,7 @@ public abstract class LauncherInput {
|
||||
});
|
||||
}
|
||||
|
||||
public static List<ActionProvider.Action> of(String input) {
|
||||
public static List<ActionProvider.Action> parseActions(String input) {
|
||||
if (input.startsWith("\"") && input.endsWith("\"")) {
|
||||
input = input.substring(1, input.length() - 1);
|
||||
}
|
||||
@@ -154,6 +154,7 @@ public abstract class OperationMode {
|
||||
|
||||
switchToSyncOrThrow(map(getStartupMode()));
|
||||
inStartup = false;
|
||||
AppOpenArguments.init();
|
||||
}
|
||||
|
||||
public static void switchToAsync(OperationMode newMode) {
|
||||
|
||||
Reference in New Issue
Block a user