Phase 2: E2EE for DM + Slint migration + dead code cleanup

- E2EE crypto (src/e2ee.rs) with X25519 key derivation from Ed25519,
  HKDF shared secret, ChaCha20-Poly1305 encrypt/decrypt
- E2EE net layer: PID 0x0071-0x0074, JSON payloads, dispatch, session handlers
- E2EE UI: lock icons in DM header and sidebar
- Slint migration: all .slint files, bridge.rs, update.rs, main.rs
- Removed egui UI (~50 files), cleaned all dead code
- Clean cargo clippy -- -D warnings
This commit is contained in:
Loki 2026-07-14 13:25:15 +02:00
parent f361b037cb
commit 03d94e0465
Signed by: boba
GPG key ID: 253067914055423B
83 changed files with 5055 additions and 9202 deletions

123
src/ui/slint/chat.slint Normal file
View file

@ -0,0 +1,123 @@
import { Theme } from "theme.slint";
export struct MessageItem {
message_id: string,
sender_id: string,
sender_name: string,
content: string,
timestamp: string,
is_own: bool,
edited: bool,
reply_to: string,
}
export struct DmConversationItem {
dm_id: string,
other_user_id: string,
other_nickname: string,
e2ee_enabled: bool,
messages: [MessageItem],
}
export struct MemberItem {
user_id: string,
nickname: string,
status: string,
}
export component ChatPanel {
in-out property <string> active-channel-id;
in-out property <string> active-channel-name;
in-out property <[MessageItem]> messages;
in-out property <[MemberItem]> members;
in-out property <string> input-text;
in-out property <bool> is-dm;
in-out property <bool> e2ee-enabled;
in-out property <string> dm-partner-name;
callback send-message(string, string);
callback load-more(string);
VerticalLayout {
padding: 0;
spacing: 0;
Rectangle {
height: 48px;
background: Theme.bg-surface;
HorizontalLayout {
padding: 8px;
spacing: 4px;
Text {
text: e2ee-enabled ? "🔒 " : "";
color: Theme.accent;
}
Text {
text: is-dm ? dm-partner-name : "#" + active-channel-name;
color: Theme.text-primary;
font-size: 16px;
}
}
}
Flickable {
VerticalLayout {
for msg in messages: Rectangle {
height: 60px;
VerticalLayout {
padding: 8px;
spacing: 4px;
HorizontalLayout {
spacing: 8px;
Text {
text: msg.sender_name;
color: Theme.accent;
font-weight: 700;
}
Text {
text: msg.timestamp;
color: Theme.text-muted;
font-size: 11px;
}
}
Text {
text: msg.content;
wrap: word-wrap;
}
}
}
}
}
Rectangle {
height: 48px;
background: Theme.bg-surface;
HorizontalLayout {
padding: 8px;
spacing: 8px;
TextInput {
text <=> input-text;
horizontal-stretch: 1;
}
Rectangle {
width: 64px;
height: 32px;
background: Theme.accent;
border-radius: Theme.radius;
TouchArea {
clicked => {
send-message(active-channel-id, input-text);
input-text = "";
}
}
Text {
text: "Send";
color: Theme.text-primary;
horizontal-alignment: center;
vertical-alignment: center;
}
}
}
}
}
}

101
src/ui/slint/connect.slint Normal file
View file

@ -0,0 +1,101 @@
import { Theme } from "theme.slint";
import { Button, ListView, LineEdit } from "std-widgets.slint";
export struct BookmarkItem {
name: string,
address: string,
}
export component ConnectScreen {
in-out property <[BookmarkItem]> bookmarks;
in-out property <string> address-input;
in-out property <string> status-text;
in-out property <bool> connecting;
in-out property <bool> auto-reconnect;
in-out property <string> node-name;
callback connect(string);
callback disconnect();
callback remove-bookmark(string);
callback add-bookmark(string);
VerticalLayout {
alignment: center;
spacing: 16px;
Text { text: "VNOX"; color: Theme.accent; font-size: 36px; font-weight: 700; }
Text { text: "Self-hosted voice & chat"; color: Theme.text-secondary; font-size: 14px; }
HorizontalLayout {
LineEdit {
text <=> address-input;
placeholder-text: "server:7600";
width: 300px;
}
Rectangle {
width: 100px;
height: 30px;
background: Theme.accent;
border-radius: 6px;
TouchArea {
enabled: !connecting;
clicked => { connect(address-input); }
}
Text {
text: connecting ? "Connecting..." : "Connect";
color: Theme.text-primary;
horizontal-alignment: center;
vertical-alignment: center;
}
}
}
Text { text: status-text; color: Theme.text-muted; }
HorizontalLayout {
Rectangle {
width: 16px;
height: 16px;
background: auto-reconnect ? Theme.accent : Theme.bg-elevated;
border-radius: 3px;
border-width: 1px;
border-color: Theme.text-muted;
TouchArea {
clicked => { auto-reconnect = !auto-reconnect; }
}
}
Text { text: "Auto-reconnect"; color: Theme.text-secondary; }
}
Text { text: "Saved Servers"; color: Theme.text-primary; font-size: 16px; }
ListView {
for bm in bookmarks: Rectangle {
height: 40px;
HorizontalLayout {
padding: 8px;
Text { text: bm.name; color: Theme.text-primary; }
Text { text: bm.address; color: Theme.text-muted; }
HorizontalLayout {
Button { text: "Connect"; clicked => { connect(bm.address); } }
Button { text: "✕"; clicked => { remove-bookmark(bm.address); } }
}
}
}
}
HorizontalLayout {
Button { text: "+ Add Server"; clicked => { add-bookmark(address-input); } }
}
Text { text: node-name; color: Theme.success; }
Rectangle {
width: 100px;
height: 30px;
background: Theme.danger;
border-radius: 6px;
visible: node-name != "";
TouchArea { clicked => { disconnect(); } }
Text { text: "Disconnect"; color: Theme.text-primary; horizontal-alignment: center; vertical-alignment: center; }
}
}
}

123
src/ui/slint/friends.slint Normal file
View file

@ -0,0 +1,123 @@
import { Theme } from "theme.slint";
export struct FriendItem {
user_id: string,
nickname: string,
status: string,
}
export component FriendsPanel {
in-out property <[FriendItem]> friends;
in-out property <[FriendItem]> pending-requests;
in-out property <[string]> blocked-users;
in-out property <string> active-tab;
in-out property <string> add-friend-input;
callback add-friend(string);
callback accept-friend(string);
callback decline-friend(string);
callback remove-friend(string);
callback start-dm(string);
VerticalLayout {
padding: 16px;
spacing: 8px;
Text {
text: "Friends";
color: Theme.text-primary;
font-size: 18px;
}
HorizontalLayout {
spacing: 4px;
Rectangle {
height: 28px;
background: Theme.bg-interactive;
border-radius: Theme.radius;
TouchArea {
clicked => { active-tab = "online"; }
}
Text { text: "Online"; color: Theme.text-primary; horizontal-alignment: center; vertical-alignment: center; }
}
Rectangle {
height: 28px;
background: Theme.bg-interactive;
border-radius: Theme.radius;
TouchArea {
clicked => { active-tab = "all"; }
}
Text { text: "All"; color: Theme.text-primary; horizontal-alignment: center; vertical-alignment: center; }
}
Rectangle {
height: 28px;
background: Theme.bg-interactive;
border-radius: Theme.radius;
TouchArea {
clicked => { active-tab = "pending"; }
}
Text { text: "Pending"; color: Theme.text-primary; horizontal-alignment: center; vertical-alignment: center; }
}
Rectangle {
height: 28px;
background: Theme.bg-interactive;
border-radius: Theme.radius;
TouchArea {
clicked => { active-tab = "blocked"; }
}
Text { text: "Blocked"; color: Theme.text-primary; horizontal-alignment: center; vertical-alignment: center; }
}
}
HorizontalLayout {
spacing: 8px;
TextInput {
text <=> add-friend-input;
horizontal-stretch: 1;
}
Rectangle {
width: 32px;
height: 32px;
background: Theme.accent;
border-radius: Theme.radius;
TouchArea {
clicked => {
add-friend(add-friend-input);
add-friend-input = "";
}
}
Text { text: "+"; color: Theme.text-primary; horizontal-alignment: center; vertical-alignment: center; }
}
}
Flickable {
VerticalLayout {
for f in friends: Rectangle {
height: 48px;
HorizontalLayout {
padding: 8px;
spacing: 8px;
Text {
text: f.nickname;
color: Theme.text-primary;
}
Text {
text: f.status;
color: Theme.text-muted;
}
Rectangle {
width: 40px;
height: 28px;
background: Theme.accent;
border-radius: Theme.radius;
TouchArea {
clicked => { start-dm(f.user_id); }
}
Text { text: "DM"; color: Theme.text-primary; horizontal-alignment: center; vertical-alignment: center; }
}
}
}
}
}
}
}

147
src/ui/slint/main.slint Normal file
View file

@ -0,0 +1,147 @@
import { Theme } from "theme.slint";
import { Sidebar, ChannelItem, GuildItem } from "sidebar.slint";
import { ChatPanel, MessageItem, MemberItem } from "chat.slint";
import { FriendsPanel, FriendItem } from "friends.slint";
import { VoicePanel, VoiceMemberItem } from "voice.slint";
import { BookmarkItem, ConnectScreen } from "connect.slint";
export component MainWindow inherits Window {
in-out property <[ChannelItem]> channels;
in-out property <[GuildItem]> guilds;
in-out property <[string]> dm-conversations;
in-out property <string> username;
in-out property <string> user-status;
in-out property <string> active-channel-id;
in-out property <int> active-guild-idx;
in-out property <string> active-channel-name;
in-out property <[MessageItem]> messages;
in-out property <[MemberItem]> members;
in-out property <string> input-text;
in-out property <bool> is-dm;
in-out property <bool> e2ee-enabled;
in-out property <string> dm-partner-name;
in-out property <bool> show-chat;
in-out property <bool> show-friends;
in-out property <bool> show-voice;
in-out property <[FriendItem]> friends;
in-out property <[FriendItem]> pending-requests;
in-out property <[string]> blocked-users;
in-out property <string> friends-active-tab;
in-out property <string> add-friend-input;
in-out property <[VoiceMemberItem]> voice-members;
in-out property <bool> mic-enabled;
in-out property <bool> deafened;
in-out property <string> voice-channel-name;
in-out property <string> activity-banner;
in-out property <[BookmarkItem]> bookmarks: [];
in-out property <string> address-input: "";
in-out property <string> status-text: "";
in-out property <bool> connecting: false;
in-out property <bool> auto-reconnect: false;
in-out property <string> node-name: "";
in-out property <string> identity-pubkey: "";
in-out property <bool> vault-enabled: false;
in-out property <string> voice-input-device: "";
in-out property <string> voice-output-device: "";
in-out property <float> voice-bitrate: 64.0;
in-out property <int> vad-mode: 0;
in-out property <float> volume: 100.0;
in-out property <string> active-tab: "audio";
callback channel-selected(string);
callback guild-selected(int);
callback dm-selected(string);
callback disconnect();
callback send-message(string, string);
callback load-more(string);
callback add-friend(string);
callback accept-friend(string);
callback decline-friend(string);
callback remove-friend(string);
callback start-dm(string);
callback toggle-mic();
callback toggle-deafen();
callback leave-voice();
callback connect(string);
callback remove-bookmark(string);
callback add-bookmark(string);
callback close-settings();
callback set-passphrase(string);
callback export-keyfile();
callback import-keyfile();
min-width: 900px;
min-height: 560px;
title: "Vnox";
background: Theme.bg-base;
if node-name == "" : ConnectScreen {
bookmarks: root.bookmarks;
address-input: root.address-input;
status-text: root.status-text;
connecting: root.connecting;
auto-reconnect: root.auto-reconnect;
node-name: root.node-name;
connect(address) => { root.connect(address); }
disconnect => { root.disconnect(); }
remove-bookmark(address) => { root.remove-bookmark(address); }
add-bookmark(address) => { root.add-bookmark(address); }
}
if node-name != "" : HorizontalLayout {
sidebar := Sidebar {
channels: root.channels;
guilds: root.guilds;
dm-conversations: root.dm-conversations;
username: root.username;
user-status: root.user-status;
active-channel-id: root.active-channel-id;
active-guild-idx: root.active-guild-idx;
channel-selected(id) => { root.channel-selected(id); }
guild-selected(idx) => { root.guild-selected(idx); }
dm-selected(id) => { root.dm-selected(id); }
disconnect => { root.disconnect(); }
}
chat-panel := ChatPanel {
visible: show-chat;
active-channel-id: root.active-channel-id;
active-channel-name: root.active-channel-name;
messages: root.messages;
members: root.members;
input-text: root.input-text;
is-dm: root.is-dm;
e2ee-enabled: root.e2ee-enabled;
dm-partner-name: root.dm-partner-name;
send-message(id, text) => { root.send-message(id, text); }
load-more(id) => { root.load-more(id); }
}
friends-panel := FriendsPanel {
visible: show-friends;
friends: root.friends;
pending-requests: root.pending-requests;
blocked-users: root.blocked-users;
active-tab: root.friends-active-tab;
add-friend-input: root.add-friend-input;
add-friend(id) => { root.add-friend(id); }
accept-friend(id) => { root.accept-friend(id); }
decline-friend(id) => { root.decline-friend(id); }
remove-friend(id) => { root.remove-friend(id); }
start-dm(id) => { root.start-dm(id); }
}
voice-panel := VoicePanel {
visible: show-voice;
members: root.voice-members;
mic-enabled: root.mic-enabled;
deafened: root.deafened;
channel-name: root.voice-channel-name;
activity-banner: root.activity-banner;
toggle-mic => { root.toggle-mic(); }
toggle-deafen => { root.toggle-deafen(); }
leave-voice => { root.leave-voice(); }
}
}
}

1
src/ui/slint/mod.rs Normal file
View file

@ -0,0 +1 @@
::slint::include_modules!();

View file

@ -0,0 +1,68 @@
import { Theme } from "theme.slint";
import { Button } from "std-widgets.slint";
export component SettingsWindow inherits Window {
title: "Settings";
width: 720px;
height: 520px;
background: Theme.bg-base;
in-out property <string> identity-pubkey;
in-out property <bool> vault-enabled;
in-out property <string> voice-input-device;
in-out property <string> voice-output-device;
in-out property <float> voice-bitrate;
in-out property <int> vad-mode;
in-out property <float> volume;
in-out property <string> active-tab;
callback close();
callback set-passphrase(string);
callback export-keyfile();
callback import-keyfile();
VerticalLayout {
HorizontalLayout {
Button { text: "Audio"; clicked => { active-tab = "audio"; } }
Button { text: "Network"; clicked => { active-tab = "network"; } }
Button { text: "Identity"; clicked => { active-tab = "identity"; } }
Button { text: "App"; clicked => { active-tab = "app"; } }
}
if active-tab == "identity": VerticalLayout {
Text { text: "Identity"; color: Theme.text-primary; font-size: 18px; }
Text { text: "Public Key: " + identity-pubkey; color: Theme.text-secondary; }
Button { text: vault-enabled ? "Remove Passphrase" : "Set Passphrase"; clicked => { set-passphrase(""); } }
Button { text: "Export Keyfile"; clicked => { export-keyfile(); } }
Button { text: "Import Keyfile"; clicked => { import-keyfile(); } }
}
if active-tab == "audio": VerticalLayout {
Text { text: "Voice Settings"; color: Theme.text-primary; font-size: 18px; }
Text { text: "Input: " + voice-input-device; color: Theme.text-secondary; }
Text { text: "Output: " + voice-output-device; color: Theme.text-secondary; }
HorizontalLayout {
Text { text: "Bitrate:"; color: Theme.text-secondary; }
Text { text: voice-bitrate; color: Theme.text-primary; }
}
HorizontalLayout {
Text { text: "VAD Mode:"; color: Theme.text-secondary; }
Text { text: vad-mode == 0 ? "PTT" : vad-mode == 1 ? "VAD" : "Always On"; color: Theme.text-primary; }
}
HorizontalLayout {
Text { text: "Volume:"; color: Theme.text-secondary; }
Text { text: volume; color: Theme.text-primary; }
}
}
if active-tab == "network": VerticalLayout {
Text { text: "Network"; color: Theme.text-primary; font-size: 18px; }
}
if active-tab == "app": VerticalLayout {
Text { text: "Appearance"; color: Theme.text-primary; font-size: 18px; }
}
Button { text: "Close"; horizontal-alignment: center; clicked => { close(); } }
}
}

View file

@ -0,0 +1,92 @@
import { Theme } from "theme.slint";
export struct ChannelItem {
channel_id: string,
name: string,
kind: string,
}
export struct GuildItem {
guild_id: string,
name: string,
}
export component Sidebar {
in-out property <[GuildItem]> guilds;
in-out property <[ChannelItem]> channels;
in-out property <[string]> dm-conversations;
in-out property <string> username;
in-out property <string> user-status;
in-out property <string> active-channel-id;
in-out property <int> active-guild-idx;
callback channel-selected(string);
callback guild-selected(int);
callback dm-selected(string);
callback disconnect();
width: 240px;
height: 100%;
Rectangle {
background: Theme.bg-base;
width: 100%;
height: 100%;
VerticalLayout {
Rectangle {
height: 48px;
background: Theme.bg-surface;
HorizontalLayout {
padding: 8px;
Text { text: "Vnox"; color: Theme.accent; font-size: 18px; }
}
}
VerticalLayout {
for item in channels: Rectangle {
height: 36px;
background: item.channel_id == active-channel-id ? Theme.bg-elevated : Theme.bg-base;
HorizontalLayout {
padding: 8px;
Text {
text: item.kind == "voice" ? "🔊 " : "# ";
color: Theme.text-secondary;
}
Text { text: item.name; color: Theme.text-primary; }
}
TouchArea {
clicked => { channel-selected(item.channel_id); }
}
}
}
VerticalLayout {
for dm in dm-conversations: Rectangle {
height: 36px;
HorizontalLayout {
padding: 8px;
Text { text: "@"; color: Theme.text-secondary; }
Text { text: dm; color: Theme.text-primary; }
}
TouchArea {
clicked => { dm-selected(dm); }
}
}
}
Rectangle {
height: 52px;
background: Theme.bg-surface;
HorizontalLayout {
padding: 8px;
Text { text: username; color: Theme.text-primary; }
Text { text: user-status; color: Theme.text-muted; }
TouchArea {
clicked => { disconnect(); }
}
}
}
}
}
}

15
src/ui/slint/theme.slint Normal file
View file

@ -0,0 +1,15 @@
export global Theme {
in-out property <color> bg-base: #181825;
in-out property <color> bg-surface: #1e1e2e;
in-out property <color> bg-hover: #2a2a3e;
in-out property <color> bg-elevated: #2a2a3e;
in-out property <color> bg-interactive: #313244;
in-out property <color> accent: #E67E22;
in-out property <color> text-primary: #cdd6f4;
in-out property <color> text-secondary: #a0a4b8;
in-out property <color> text-muted: #6c7086;
in-out property <color> text-disabled: #45475a;
in-out property <color> danger: #f38ba8;
in-out property <color> success: #a6e3a1;
in-out property <length> radius: 8px;
}

99
src/ui/slint/voice.slint Normal file
View file

@ -0,0 +1,99 @@
import { Theme } from "theme.slint";
export struct VoiceMemberItem {
user_id: string,
nickname: string,
speaking: bool,
}
export component VoicePanel {
in-out property <[VoiceMemberItem]> members;
in-out property <bool> mic-enabled;
in-out property <bool> deafened;
in-out property <string> channel-name;
in-out property <string> activity-banner;
callback toggle-mic();
callback toggle-deafen();
callback leave-voice();
VerticalLayout {
padding: 16px;
spacing: 8px;
Text {
text: "🔊 " + channel-name;
color: Theme.text-primary;
}
Text {
text: activity-banner;
color: Theme.text-muted;
}
Flickable {
VerticalLayout {
for m in members: Rectangle {
height: 48px;
HorizontalLayout {
padding: 8px;
spacing: 8px;
Rectangle {
width: 12px;
height: 12px;
border-radius: 6px;
background: m.speaking ? Theme.success : Theme.text-muted;
}
Text {
text: m.nickname;
color: Theme.text-primary;
}
}
}
}
}
HorizontalLayout {
spacing: 8px;
Rectangle {
height: 32px;
background: Theme.accent;
border-radius: Theme.radius;
TouchArea {
clicked => { toggle-mic(); }
}
Text {
text: mic-enabled ? "Mute" : "Unmute";
color: Theme.text-primary;
horizontal-alignment: center;
vertical-alignment: center;
}
}
Rectangle {
height: 32px;
background: Theme.accent;
border-radius: Theme.radius;
TouchArea {
clicked => { toggle-deafen(); }
}
Text {
text: deafened ? "Undeafen" : "Deafen";
color: Theme.text-primary;
horizontal-alignment: center;
vertical-alignment: center;
}
}
Rectangle {
height: 32px;
background: Theme.danger;
border-radius: Theme.radius;
TouchArea {
clicked => { leave-voice(); }
}
Text {
text: "Leave";
color: Theme.text-primary;
horizontal-alignment: center;
vertical-alignment: center;
}
}
}
}
}