mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-09-28 23:31:43 +12:00
Local askpass fixes
This commit is contained in:
parent
56048bd5e3
commit
872406fc4c
7 changed files with 90 additions and 1 deletions
|
@ -0,0 +1,44 @@
|
|||
package io.xpipe.app.exchange;
|
||||
|
||||
import io.xpipe.app.core.AppI18n;
|
||||
import io.xpipe.app.core.AppWindowHelper;
|
||||
import io.xpipe.app.core.mode.OperationMode;
|
||||
import io.xpipe.app.fxcomps.impl.SecretFieldComp;
|
||||
import io.xpipe.beacon.BeaconHandler;
|
||||
import io.xpipe.beacon.exchange.AskpassExchange;
|
||||
import io.xpipe.core.util.SecretValue;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
import javafx.scene.control.Alert;
|
||||
|
||||
public class AskpassExchangeImpl extends AskpassExchange
|
||||
implements MessageExchangeImpl<AskpassExchange.Request, AskpassExchange.Response> {
|
||||
|
||||
@Override
|
||||
public Response handleRequest(BeaconHandler handler, Request msg) throws Exception {
|
||||
OperationMode.switchTo(OperationMode.GUI);
|
||||
|
||||
// SecretValue set = AppCache.get(msg.getId(), SecretValue.class, () -> null);
|
||||
// if (set != null) {
|
||||
// return Response.builder().value(set).build();
|
||||
// }
|
||||
|
||||
var prop =
|
||||
new SimpleObjectProperty<SecretValue>();
|
||||
var r = AppWindowHelper.showBlockingAlert(alert -> {
|
||||
alert.setTitle(AppI18n.get("askpassAlertTitle"));
|
||||
alert.setHeaderText(msg.getPrompt());
|
||||
alert.setAlertType(Alert.AlertType.CONFIRMATION);
|
||||
|
||||
var text = new SecretFieldComp(prop).createRegion();
|
||||
text.setStyle("-fx-border-width: 1px");
|
||||
alert.getDialogPane().setContent(text);
|
||||
})
|
||||
.filter(b -> b.getButtonData().isDefaultButton() && prop.getValue() != null)
|
||||
.map(t -> {
|
||||
//AppCache.update(msg.getId(), prop.getValue());
|
||||
return prop.getValue();
|
||||
})
|
||||
.orElse(null);
|
||||
return Response.builder().value(r != null ? r.getSecretValue() : null).build();
|
||||
}
|
||||
}
|
|
@ -71,7 +71,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
|
|||
|
||||
@Override
|
||||
protected String toCommand(String name, String command) {
|
||||
return "--new-tab -e bash -c " + command;
|
||||
return "--new-tab -e " + command;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -164,6 +164,7 @@ open module io.xpipe.app {
|
|||
RemoveEntryExchangeImpl,
|
||||
RenameCollectionExchangeImpl,
|
||||
RenameEntryExchangeImpl,
|
||||
AskpassExchangeImpl,
|
||||
SourceProviderListExchangeImpl,
|
||||
QueryStoreExchangeImpl,
|
||||
SelectExchangeImpl,
|
||||
|
|
|
@ -5,6 +5,7 @@ lf=LF (Linux)
|
|||
none=None
|
||||
common=Common
|
||||
other=Other
|
||||
askpassAlertTitle=Askpass
|
||||
nullPointer=Null Pointer
|
||||
mustNotBeEmpty=$NAME$ must not be empty
|
||||
null=$VALUE$ must be not null
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
package io.xpipe.beacon.exchange;
|
||||
|
||||
import io.xpipe.beacon.RequestMessage;
|
||||
import io.xpipe.beacon.ResponseMessage;
|
||||
import lombok.Builder;
|
||||
import lombok.NonNull;
|
||||
import lombok.Value;
|
||||
import lombok.extern.jackson.Jacksonized;
|
||||
|
||||
public class AskpassExchange implements MessageExchange {
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return "askpass";
|
||||
}
|
||||
|
||||
@Jacksonized
|
||||
@Builder
|
||||
@Value
|
||||
public static class Request implements RequestMessage {
|
||||
@NonNull
|
||||
String id;
|
||||
String prompt;
|
||||
}
|
||||
|
||||
@Jacksonized
|
||||
@Builder
|
||||
@Value
|
||||
public static class Response implements ResponseMessage {
|
||||
String value;
|
||||
}
|
||||
}
|
|
@ -68,6 +68,7 @@ module io.xpipe.beacon {
|
|||
WritePreparationExchange,
|
||||
ProxyReadConnectionExchange,
|
||||
WriteExecuteExchange,
|
||||
AskpassExchange,
|
||||
SelectExchange,
|
||||
ReadExchange,
|
||||
QueryTextDataExchange,
|
||||
|
|
|
@ -269,4 +269,14 @@ public class XPipeInstallation {
|
|||
return FileNames.join("Content", "MacOS", "xpiped");
|
||||
}
|
||||
}
|
||||
|
||||
public static String getRelativeCliExecutablePath(OsType type) {
|
||||
if (type.equals(OsType.WINDOWS)) {
|
||||
return FileNames.join("cli", "xpipe.exe");
|
||||
} else if (type.equals(OsType.LINUX)) {
|
||||
return FileNames.join("cli", "bin", "xpipe");
|
||||
} else {
|
||||
return FileNames.join("Content", "MacOS", "xpipe");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue