diff --git a/.github/banner.png b/.github/banner.png new file mode 100644 index 0000000..44a6368 Binary files /dev/null and b/.github/banner.png differ diff --git a/README.md b/README.md index d152a35..777d900 100644 --- a/README.md +++ b/README.md @@ -1 +1,61 @@ -# gui \ No newline at end of file +D-Modem/gui: D-Modem on the desktop + +# D-Modem desktop apps + +Native apps for D-Modem on Windows, macOS and Linux. + +Each app starts dmodemd (or reaches one that already runs), and shows the +modem as a desktop program should: dial and answer from a window, change +its settings without AT commands, and see how the last call went. All three +are thin native shells over one small C library, libdmodemctl, so they +behave the same. + +- **Modem**: the call's state, dial, answer and hang up, and the line it uses +- **Terminal**: the AT console, and the modem's own setup screens (AT!CF, AT!CT) +- **Settings**: every modem setting as a native control, from AT!M +- **Call Stats**: the last call's rate, modulation, error control and line figures (AT#UD, ATI11) +- **Line settings**: a SIP account, a USB modem, or a modem that already runs +- **Windows 95 and later**: plain Win32, built with Open Watcom; on Windows 9x it reaches a modem over TCP or a COM port + +| | Windows | macOS | Linux | +| --- | --- | --- | --- | +| Toolkit | Win32, C++ | SwiftUI | GTK 4, libadwaita, VTE | +| Runs on | Windows 95 and later | macOS 13 and later | GNOME 46 era and later | + +The Linux app's Settings page The Windows app's Terminal with the modem's setup screen + +## Quick start + +Linux: + + sudo apt install cmake libgtk-4-dev libadwaita-1-dev libvte-2.91-gtk4-dev + cmake -S . -B build && cmake --build build && ./build/linux/dmodem-gui + +Windows: `cmake -S . -B build -A Win32 && cmake --build build --config Release`, +or for Windows 95 and later, `windows/build-watcom.sh` with Open Watcom 2.0. + +macOS: `brew install xcodegen && cd macos && xcodegen && open DModem.xcodeproj`. + +The apps need D-Modem 1.0 or later, whose dmodemd has AT!M. + +## Documentation + +- [Design](docs/design.md): how the apps are built, what they share, and the Windows 9x notes +- [libdmodemctl](core/include/dmodemctl.h): the library's API + +## The D-Modem suite + +| Repository | What it is | +| --- | --- | +| [D-Modem](https://github.com/D-Modem/D-Modem) | The open V.92 softmodem: dmodemd, libdmodem and the Asterisk, FreeSWITCH and ARI modules | +| [app](https://github.com/D-Modem/app) | The D-Modem app for Android and iOS: a dial-up modem on a SIP call | +| [gui](https://github.com/D-Modem/gui) | D-Modem on the desktop: native apps for Windows, macOS and Linux | +| [hardware](https://github.com/D-Modem/hardware) | pico-serial: RP2040 serial adapters and phone-line USB sticks | +| [menu](https://github.com/D-Modem/menu) | modemmenu: the login and menu dial-up callers reach | +| [bbs](https://github.com/D-Modem/bbs) | A bulletin board for telnet, SSH, TN3270 and modem callers | +| [go3270](https://github.com/D-Modem/go3270) | A Go library for 3270 terminal servers, used by bbs | +| [brand](https://github.com/D-Modem/brand) | Logos, colours, type and the naming guide | + +## Licence + +BSD 3-Clause ([LICENSE](LICENSE)). diff --git a/docs/design.md b/docs/design.md new file mode 100644 index 0000000..854bdba --- /dev/null +++ b/docs/design.md @@ -0,0 +1,81 @@ +# Design + +## One library, three native shells + +The apps share everything that is not drawing. `core/` is libdmodemctl, a +small C library with no I/O and no threads ("sans-I/O"): each app opens the +modem in its own way, hands the bytes it reads to `dmc_feed()`, writes what +`dmc_output()` gives it, and calls `dmc_poll()` from a 50 ms timer. That +keeps it easy to call from C (GTK), C++ (Win32) and Swift, and easy to test +(`core/test`, run by CI with ASan and UBSan). + +| Part | What it does | +| --- | --- | +| `dmc_session` | The AT conversation: a queue of commands and their responses, the call's state from the result codes (RING, CONNECT, NO CARRIER), caller ID, the escape (`+++` with its guard times) and hanging up, and the byte stream for the terminal | +| `dmc_model` | The modem's settings from AT!M, with each setting's check and the command that sets it | +| `dmc_diag` | The last call's statistics from AT#UD, as labelled rows (the V.58 code tables decoded) | +| `dmc_vt` | A small VT100/ANSI screen, for Windows and macOS, whose toolkits have no terminal widget | +| `dmc_daemon_*` | Reading what dmodemd prints when it starts: the device it made, or its error | + +## Where the settings come from + +dmodemd's core has one settings model (`Config::model`), which already +drives its configurators (AT!CF, AT!CT, AT!C). AT!M prints that model as +tab-separated lines: each setting's key, kind (pick, number or text), +value, default, range, AT form, group, label and help, then each choice. +The Settings page builds its controls from it, so a setting added to the +modem shows in every app with no change here. A change is checked by the +library, sent as its AT command, and kept once the modem says OK. + +The modem keeps no stored profile, so the page shows AT!R's init string +and its **Keep** button saves it in the app's line settings, to be sent +each time the modem opens. + +## The same screens everywhere + +Each app has the same five pages, with the same words: + +| Page | Contents | +| --- | --- | +| Modem | The state ("Idle", "Dialling", "Online") and its detail (the CONNECT line, the caller), Dial, Answer, Hang Up, the line and the device, Start or Stop | +| Terminal | The AT console; the buttons **Full-screen setup** (AT!CF) and **Command-line setup** (AT!CT) | +| Settings | Groups of settings as native controls, changed ones marked; Defaults (ATZ), the init string and Keep | +| Call Stats | AT#UD's rows and ATI11's report, refreshed after each call | +| Log | What dmodemd printed, and the command line it was started with | + +The terminal sends Backspace as BS (0x08), the modem's S5: it does not take +DEL. Colours are the brand's: background `#0a0f1c`, text `#e8f0ff`. + +## Starting dmodemd + +| | Linux | macOS | Windows | +| --- | --- | --- | --- | +| Started with | GSubprocess | Process | CreateProcess | +| Its DTE | a pty (it prints "Use `/dev/pts/N' as modem device") | a pty | `--tcp 127.0.0.1:port` | +| Settings kept in | `~/.config/dmodem-gui/settings.ini` (mode 0600) | user defaults, the SIP password in the keychain | `%APPDATA%\D-Modem\dmodem.ini` | + +The SIP account goes to dmodemd in its environment (`SIP_LOGIN`, +`SIP_T38`, `SIP_V152`, `SIP_V150`, `SIP_SRTP`); the country, USB modem and +debug level as flags. On Linux and macOS the pty is made in the user's +own group (`-g`), so that dmodemd needs no root. + +Each app can instead use a modem that already runs: a device path on +Linux and macOS; a TCP address or a COM port on Windows. + +## Windows 95 and later + +The Windows app is plain Win32 in C++98, so that one binary runs from +Windows 95 to Windows 11: + +- ANSI APIs, with UTF-8 from the library converted by hand (no `CP_UTF8` + on 9x); the terminal draws with `ExtTextOutW`, which 9x has. +- The Windows 95 common controls (tabs, list views, the status bar), + Winsock 1.1 (`wsock32`, `WSAAsyncSelect`) and the 4.0 `OPENFILENAME`. +- No `SetHandleInformation` (NT only): the pipe from dmodemd is made + non-inheritable with `DuplicateHandle`. +- Built by Open Watcom 2.0 (`windows/build-watcom.sh`: `runtime + windows=4.0`, the static C library), as CI does; MinGW and MSVC build the + same code with CMake. + +dmodemd itself needs Windows 7 or later. On Windows 9x and NT 4 the app +defaults to a COM port, and can reach a dmodemd on another machine over TCP.