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]>
63 lines
2.5 KiB
Swift
63 lines
2.5 KiB
Swift
// The Network pane: how a machine name becomes an address, and which addresses
|
|
// are allowed to become a connection.
|
|
//
|
|
// "IP address mapping" / "Resolve machine's IP address using manually entered
|
|
// mappings below" / "Example: MyLaptop 192.168.0.24" / "Validate remote machine
|
|
// IP" / "Same subnet only" are the modern page's
|
|
// (`MouseWithoutBordersPage.xaml:274-286, 399-425`). The per-line format is
|
|
// `Name2IP` as the resolver reads it (docs/protocol.md §7).
|
|
|
|
import Foundation
|
|
import MWBCore
|
|
import SwiftUI
|
|
|
|
/// Name resolution and the two connection filters.
|
|
struct NetworkPane: View {
|
|
@ObservedObject var model: SettingsViewModel
|
|
|
|
var body: some View {
|
|
SettingsPaneLayout {
|
|
SettingsSection(
|
|
"IP address mapping",
|
|
note:
|
|
"Resolve a machine's IP address using the mappings below, for machines DNS "
|
|
+ "and Bonjour cannot find. One per line: the machine name, a space, then "
|
|
+ "its address. Example: MyLaptop 192.168.0.24"
|
|
) {
|
|
TextEditor(text: $model.name2IPDraft)
|
|
.font(.system(.body, design: .monospaced))
|
|
.frame(height: 110)
|
|
.border(.separator)
|
|
HStack {
|
|
Button("Save mappings") { model.saveName2IP() }
|
|
Spacer()
|
|
}
|
|
}
|
|
|
|
SettingsSection("Connection rules") {
|
|
SettingsToggle(
|
|
"Validate remote machine IP",
|
|
help: "Reverse DNS lookup to validate the machine's IP address.",
|
|
isOn: model.binding(\.validateRemoteMachineIP))
|
|
SettingsToggle(
|
|
"Same subnet only",
|
|
help:
|
|
"Only connect to machines in the same intranet NNN.NNN.*.* (only works "
|
|
+ "when both machines have IPv4 enabled).",
|
|
isOn: model.binding(\.sameSubnetOnly))
|
|
}
|
|
|
|
SettingsSection(
|
|
"If nothing connects",
|
|
note:
|
|
"Both machines must use the same security key and port, must list each "
|
|
+ "other's host name in the device layout, and must be able to resolve that "
|
|
+ "name. macOS asks for permission the first time the app accepts an "
|
|
+ "incoming connection — allow it, or the listener never opens."
|
|
) {
|
|
EmptyView()
|
|
}
|
|
}
|
|
}
|
|
}
|