Files
gui/macos/DModem/DModemApp.swift
T
Claude 9b2206e29a Add voice calls and a local answering machine
libdmodemctl now drives dmodemd's V.253 voice mode: placing and
answering voice calls, the DLE stream and its events, G.711 mu-law,
DTMF, and an answering machine (greeting, beep, recording) that takes
messages as WAV files. It is off until the user turns it on.

Each app gains a Phone page: Linux (PulseAudio), Windows (waveOut and
waveIn, Windows 95 and later) and macOS (AVAudioEngine).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRTvbHMpudRfQWK4c4H
2026-11-11 12:15:46 +00:00

53 lines
1.5 KiB
Swift

// SPDX-License-Identifier: AGPL-3.0-only
// Copyright (C) 2026 D-Modem Authors
//
// DModemApp.swift - the app: its window, menus and the line settings
import SwiftUI
@main
struct DModemApp: App {
@NSApplicationDelegateAdaptor(AppDelegate.self) var delegate
@StateObject private var modem = Modem()
var body: some Scene {
Window("D-Modem", id: "main") {
ContentView()
.environmentObject(modem)
.environmentObject(modem.voice)
.frame(minWidth: 760, minHeight: 520)
.onAppear { delegate.modem = modem }
}
.commands {
CommandMenu("Modem") {
Button(modem.running ? "Stop" : "Start") {
modem.running ? modem.stop() : modem.start()
}
.keyboardShortcut("r")
Divider()
Button("Answer") { modem.answer() }
.disabled(modem.state != Int(DMC_RINGING))
Button("Hang Up") { modem.hangUp() }
.keyboardShortcut(".")
.disabled(!modem.canHangUp)
}
}
Settings {
LineSettingsView()
.environmentObject(modem)
}
}
}
final class AppDelegate: NSObject, NSApplicationDelegate {
weak var modem: Modem?
func applicationShouldTerminateAfterLastWindowClosed(_ app: NSApplication) -> Bool {
true
}
func applicationWillTerminate(_ notification: Notification) {
modem?.stop()
}
}