54 lines
2 KiB
Text
54 lines
2 KiB
Text
import { Theme } from "../theme.slint";
|
|
import { Icons } from "../components/icon.slint";
|
|
import { Dialog } from "../components/dialog.slint";
|
|
import { ButtonKind } from "../components/button.slint";
|
|
|
|
// A server key to decide on (net_bridge.rs). `changed`: the key differs from the saved one,
|
|
// so the connection is refused and the dialog only warns.
|
|
export struct HostKeyData {
|
|
host: string,
|
|
key-type: string,
|
|
fingerprint: string,
|
|
changed: bool,
|
|
}
|
|
|
|
// `answered(0)` refuses, 1 connects this once, 2 connects and remembers the key.
|
|
export component HostKeyDialog inherits Dialog {
|
|
in property <HostKeyData> data;
|
|
callback answered(int);
|
|
|
|
glyph: root.data.changed ? Icons.warning : Icons.lock;
|
|
title: root.data.changed ? "The host key changed" : "Connect to a new host?";
|
|
body: root.data.changed
|
|
? "The key of " + root.data.host + " is not the one saved before. Someone may be intercepting the connection, or the server was set up again. Tunal did not connect."
|
|
: "Tunal hasn't connected to " + root.data.host + " before. Check that this fingerprint matches the one on the server.";
|
|
dialog-width: 480px;
|
|
actions: root.data.changed
|
|
? [{ text: "Close", kind: ButtonKind.filled }]
|
|
: [{ text: "Cancel", kind: ButtonKind.text }, { text: "Connect once", kind: ButtonKind.tonal }, { text: "Trust and connect", kind: ButtonKind.filled }];
|
|
// Enter and Escape never trust a key.
|
|
default-action: 0;
|
|
cancel-action: 0;
|
|
action(i) => {
|
|
root.answered(i);
|
|
}
|
|
|
|
VerticalLayout {
|
|
spacing: Theme.space-1;
|
|
|
|
Text {
|
|
text: root.data.key-type + " key";
|
|
color: Theme.on-surface-variant;
|
|
font-size: Theme.label-medium.size;
|
|
font-weight: Theme.label-medium.weight;
|
|
}
|
|
|
|
Text {
|
|
text: root.data.fingerprint;
|
|
color: Theme.on-surface;
|
|
font-size: Theme.body-medium.size;
|
|
font-weight: Theme.body-medium.weight;
|
|
wrap: word-wrap;
|
|
}
|
|
}
|
|
}
|