The real user interface, replacing app-engine's placeholder status item. - MWBMac/StatusItem.swift: NSStatusItem with a code-drawn icon, the documented status colours (doc/devdocs/modules/mousewithoutborders.md) and the menu the Windows tray menu offers (frmScreen.Designer.cs:91-180). - MWBMac/SettingsWindow/*: one NSWindow hosting a SwiftUI TabView with six panes; every property in README §Settings is reachable. Labels and help text taken from MouseWithoutBordersPage.xaml + Resources.resw, cited per file. - MWBMac/Notifications.swift, LaunchAgent.swift: UNUserNotificationCenter and SMAppService.mainApp, both guarded on a bundle identifier. - mwb/UIBridge.swift: EngineSnapshot -> StatusModel, clicks -> Engine, and the connected/lost/invalid-key notification diff. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
91 lines
3.5 KiB
Swift
91 lines
3.5 KiB
Swift
// The Security pane: the shared key every packet is encrypted with, and the port
|
|
// the matrix talks on.
|
|
//
|
|
// "Encryption key" / "Security key" / "To set up, generate the key on one
|
|
// machine, and enter it manually on other machines" / "New key" are the modern
|
|
// page's words (`MouseWithoutBordersPage.xaml:40-77`,
|
|
// `MouseWithoutBorders_SecurityKey.Description`); the grouped display form and
|
|
// the 16-character minimum are `Encryption.cs:65-79, 209-242`.
|
|
//
|
|
// Both fields are drafts: changing either tears down and rebuilds every
|
|
// connection, so they are saved together on a button press, which is what the
|
|
// Windows form's single "&Apply" does ("Save changes and reconnect to the
|
|
// machines in the matrix", `frmMatrix.Designer.cs:440-441`).
|
|
|
|
import Foundation
|
|
import MWBCore
|
|
import SwiftUI
|
|
|
|
/// The key and port editor.
|
|
struct SecurityPane: View {
|
|
@ObservedObject var model: SettingsViewModel
|
|
|
|
var body: some View {
|
|
SettingsPaneLayout {
|
|
SettingsSection(
|
|
"Security key",
|
|
note:
|
|
"To set up, generate the key on one machine, and enter it manually on the "
|
|
+ "other machines. Every machine in the matrix — Windows included — must "
|
|
+ "use the same key, or the connection is refused."
|
|
) {
|
|
HStack(spacing: 8) {
|
|
keyField
|
|
Button(model.showSecurityKey ? "Hide" : "Show") {
|
|
model.showSecurityKey.toggle()
|
|
}
|
|
}
|
|
HStack(spacing: 8) {
|
|
Button("New key") { model.generateKey() }
|
|
Button("Copy") { model.copyKey() }
|
|
Spacer()
|
|
}
|
|
if !model.securityKeyIsValid {
|
|
Text(
|
|
"At least \(SecurityKey.minimumLength) characters; spaces are ignored."
|
|
)
|
|
.font(.callout).foregroundStyle(.red)
|
|
}
|
|
}
|
|
|
|
SettingsSection(
|
|
"Port",
|
|
note:
|
|
"The data port. The control channel listens on the next port up, so 15100 "
|
|
+ "also uses 15101. Every machine in the matrix must agree, and both ports "
|
|
+ "have to be open in any firewall."
|
|
) {
|
|
HStack(spacing: 8) {
|
|
TextField("15100", text: $model.portDraft)
|
|
.textFieldStyle(.roundedBorder)
|
|
.frame(width: 100)
|
|
Spacer()
|
|
}
|
|
}
|
|
|
|
HStack(spacing: 8) {
|
|
Button("Save and reconnect") { model.saveConnection() }
|
|
.keyboardShortcut(.defaultAction)
|
|
Button("Revert") { model.refreshDrafts() }
|
|
Spacer()
|
|
}
|
|
|
|
NotYetActive(
|
|
text:
|
|
"The key is stored in the settings file in the clear, as it is on Windows, "
|
|
+ "so the file is written readable by you only.")
|
|
}
|
|
}
|
|
|
|
@ViewBuilder private var keyField: some View {
|
|
if model.showSecurityKey {
|
|
TextField("Security key", text: $model.securityKeyDraft)
|
|
.textFieldStyle(.roundedBorder)
|
|
.font(.system(.body, design: .monospaced))
|
|
} else {
|
|
SecureField("Security key", text: $model.securityKeyDraft)
|
|
.textFieldStyle(.roundedBorder)
|
|
}
|
|
}
|
|
}
|