diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 955b669..065720e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -172,7 +172,7 @@ jobs: path: build/win7/windows/dmodem.exe # The Windows app for Linux and macOS (winport/), over the portable - # Win32 layer of clang-retro MFC. First pass: TCP and SSH only. + # Win32 layer of clang-retro MFC. winport-linux: name: Windows app on Linux (clang-retro MFC's Win32 layer) runs-on: ubuntu-24.04 diff --git a/README.md b/README.md index fc3fdce..03875fb 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ libdmodemctl. Thus they operate in the same way. - **Call Stats**: the rate, modulation, error control and line figures of the last call (AT#UD, ATI11) - **Line settings**: a SIP account, a USB modem, or a modem that already runs (dmodemd, or a hardware modem such as the MultiTech MT9234MU) - **Windows 95 and later**: plain Win32, built with [clang-retro](https://clang-retro.github.io/). The modem is built in on each Windows. The app can also connect to a modem through TCP or a COM port -- **The Windows app on Linux and macOS** (first pass): the same Win32 code, built over the portable Win32 layer of [clang-retro MFC](https://github.com/clang-retro/mfc). At this time, it connects to a modem through TCP only, and the Phone page cannot play or record sound. Refer to "The Windows app on Linux and macOS" in [Design](docs/design.md) +- **The Windows app on Linux and macOS**: the same Win32 code, built over the portable Win32 layer of [clang-retro MFC](https://github.com/clang-retro/mfc). It starts dmodemd, or connects to a modem through TCP or a COM port. Refer to "The Windows app on Linux and macOS" in [Design](docs/design.md) | | Windows | macOS | Linux | | --- | --- | --- | --- | diff --git a/assets/dmodem.svg b/assets/dmodem.svg index 66401ab..aa9616c 100644 --- a/assets/dmodem.svg +++ b/assets/dmodem.svg @@ -1,5 +1,15 @@ - - - - + + + + + + + + + + + + + + diff --git a/docs/design.md b/docs/design.md index 4ff5128..88e21b1 100644 --- a/docs/design.md +++ b/docs/design.md @@ -535,43 +535,33 @@ connect to a dmodemd on another machine through TCP. ## The Windows app on Linux and macOS -The Windows app also builds for Linux and macOS. This is a first pass. -clang-retro MFC has a portable Win32 layer (`port/`, `libwinport.a`). The -layer supplies the Win32 API on X11, Wayland and Cocoa. The app links -with this layer and not with Windows. Its source code is the same as on -Windows. +The Windows app also builds for Linux and macOS. clang-retro MFC has a +portable Win32 layer (`port/`, `libwinport.a`). The layer supplies the +Win32 API on X11, Wayland and Cocoa: windows and controls, Winsock, +files, COM ports, processes and pipes, and sound (`waveOut`, `waveIn` +and ACM). The app links with this layer and not with Windows. Its source +code is the same as on Windows. - Use `-DDMODEM_GUI_WINPORT=ON` and set `CLANG_RETRO_MFC` to a checkout of clang-retro MFC. Use clang. `winport/CMakeLists.txt` builds `libwinport.a` with the Makefile of MFC. It converts `app.rc` to C++ with `port/tools/res2cpp.py` (this needs `llvm-rc`). The app is - `winport/dmodem-win32` in the build directory. + `winport/dmodem-win32` in the build directory. `windows/sources.cmake` + is the list of sources for the two builds. - `DMODEM_WINPORT` is defined for this build. The app uses it in these locations only: - - The settings file is `~/.config/D-Modem/dmodem.ini`. - - The line is TCP by default (`127.0.0.1:2323`, a dmodemd that runs). - The app does not start dmodemd on these systems yet. - - SSH uses `~/.ssh` and `/` in paths. - - The path view on the Settings page draws its pictures from Unicode - (DejaVu Sans), because these systems do not have Wingdings. - - The group boxes go under the other controls. The hit test of the - layer stops at a window that answers `HTTRANSPARENT`, and does not - try the windows under it. Windows tries them. Thus without this - change, a click on a control in a group box goes to the page. -- The layer does not have these functions yet. `winport/include` and - `winport/src/stubs.cpp` supply stand-ins for them: - - | Function | The stand-in | - | --- | --- | - | `waveOut*`, `waveIn*` (`mmsystem.h`), `acm*` (`msacm.h`) | Returns `MMSYSERR_NODRIVER`. The Phone page cannot play or record. | - | `GetCommState`, `SetCommState`, `SetCommTimeouts`, `SetCommBreak`, `ClearCommBreak` (COM ports) | Returns `FALSE` (`ERROR_NOT_SUPPORTED`). Do not use a COM port. | - | `CreatePipe`, `PeekNamedPipe` | Returns `FALSE`. The app cannot start dmodemd. | - | `GetEnvironmentStrings`, `GetUserName`, `Beep` | Uses `environ`, `$USER` and `MessageBeep`. | - | `ListView_*`, `TabCtrl_*` (`commctrl.h`), `winsock.h` | Macros and an include of `winsock2.h`. | - - When the layer gets these functions, remove the stand-ins (and the - group box change). Each stand-in is in `winport/` only, or in a - `DMODEM_WINPORT` block. -- CI builds the app on Linux and macOS. On Linux, it starts the app in - Xvfb with `winport/test/smoke.sh`. The test makes sure that the app - stays up and sends AT commands to a test modem through TCP. + - The settings file is in the `CSIDL_APPDATA` folder of the layer + (`~/.config/D-Modem` on Linux, `~/Library/Application Support/D-Modem` + on macOS). On Windows, the app uses `APPDATA`, because Windows 95 has + no `SHGetFolderPath`. + - The line is dmodemd by default. The layer tells the app that Windows + is version 5, and on Windows the app then uses a COM port by default. + - dmodemd is `dmodemd` next to the app, or else on the `PATH`. + - SSH uses `~/.ssh` and `/` in paths, because libssh uses POSIX paths + on these systems. +- The layer changes a COM port name to a device: `COM1` is `/dev/ttyS0`. +- CI builds the app on Linux and macOS. On Linux, `winport/test/smoke.sh` + starts the app in Xvfb two times: with a TCP line, and with a dmodemd + that the app starts (`winport/test/dmodemd`, a test dmodemd). Each time, + the test makes sure that the app stays up and sends AT commands to a + test modem. diff --git a/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_128x128.png b/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_128x128.png index a9a3574..3cda607 100644 Binary files a/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_128x128.png and b/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_128x128.png differ diff --git a/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_128x128@2x.png b/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_128x128@2x.png index 8147104..46b4c49 100644 Binary files a/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_128x128@2x.png and b/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_128x128@2x.png differ diff --git a/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_16x16.png b/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_16x16.png index 6525d31..668f3ec 100644 Binary files a/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_16x16.png and b/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_16x16.png differ diff --git a/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_16x16@2x.png b/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_16x16@2x.png index eb8e724..8e26efc 100644 Binary files a/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_16x16@2x.png and b/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_16x16@2x.png differ diff --git a/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_256x256.png b/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_256x256.png index 8147104..46b4c49 100644 Binary files a/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_256x256.png and b/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_256x256.png differ diff --git a/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_256x256@2x.png b/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_256x256@2x.png index 2db19da..632546b 100644 Binary files a/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_256x256@2x.png and b/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_256x256@2x.png differ diff --git a/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_32x32.png b/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_32x32.png index eb8e724..8e26efc 100644 Binary files a/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_32x32.png and b/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_32x32.png differ diff --git a/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_32x32@2x.png b/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_32x32@2x.png index 8a12ac9..a3e5c33 100644 Binary files a/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_32x32@2x.png and b/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_32x32@2x.png differ diff --git a/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_512x512.png b/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_512x512.png index 2db19da..632546b 100644 Binary files a/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_512x512.png and b/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_512x512.png differ diff --git a/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_512x512@2x.png b/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_512x512@2x.png index 6a072a2..caa1cde 100644 Binary files a/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_512x512@2x.png and b/macos/DModem/Assets.xcassets/AppIcon.appiconset/icon_512x512@2x.png differ diff --git a/tools/icons.js b/tools/icons.js index 8065ff4..551b624 100644 --- a/tools/icons.js +++ b/tools/icons.js @@ -1,4 +1,4 @@ -// Renders assets/dmodem.svg (D-Modem/brand's app icon on a tile) to the +// Renders assets/dmodem.svg (D-Modem/brand's mark, avatar/org-avatar.svg, on a tile) to the // PNGs the apps' icons are made from, with Playwright's Chromium: // node tools/icons.js && python3 tools/icons.py const { chromium } = require('playwright'); diff --git a/windows/res/dmodem.ico b/windows/res/dmodem.ico index fe271c5..24ce7f3 100644 Binary files a/windows/res/dmodem.ico and b/windows/res/dmodem.ico differ diff --git a/windows/src/app.h b/windows/src/app.h index 25b4cfd..f9ae490 100644 --- a/windows/src/app.h +++ b/windows/src/app.h @@ -47,14 +47,16 @@ #endif /* the separator of paths that libssh and the C library see: Windows', or - POSIX on Linux and macOS (winport/); and the name of the folder that - holds .ssh */ + POSIX on Linux and macOS (winport/); the name of the folder that holds + .ssh; and dmodemd's file name */ #ifdef DMODEM_WINPORT #define DIR_SEP "/" #define PROFILE_NAME "home folder" +#define DMODEMD_EXE "dmodemd" #else #define DIR_SEP "\\" #define PROFILE_NAME "profile" +#define DMODEMD_EXE "dmodemd.exe" #endif /* (older headers, Open Watcom's among them, without the 64-bit names) */ diff --git a/windows/src/config.cpp b/windows/src/config.cpp index 824ff39..fbee311 100644 --- a/windows/src/config.cpp +++ b/windows/src/config.cpp @@ -13,6 +13,9 @@ #include "app.h" #include #include "resource.h" +#ifdef DMODEM_WINPORT +#include +#endif #ifndef OPENFILENAME_SIZE_VERSION_400 #define OPENFILENAME_SIZE_VERSION_400 76 @@ -22,11 +25,12 @@ void app_data_dir(char *out, int n) { char dir[MAX_PATH]; #ifdef DMODEM_WINPORT - /* (Linux and macOS, winport/: ~/.config/D-Modem) */ - const char *home = getenv("HOME"); - if (home && strlen(home) < sizeof(dir) - 20) { - _snprintf(dir, sizeof(dir), "%s/.config", home); - CreateDirectory(dir, NULL); + /* (Linux and macOS, winport/: the layer's CSIDL_APPDATA, ~/.config or + ~/Library/Application Support; Windows 95 has no SHGetFolderPath, + so Windows uses APPDATA) */ + if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, + NULL, 0, dir)) && + strlen(dir) < sizeof(dir) - 10) { strcat(dir, "/D-Modem"); CreateDirectory(dir, NULL); _snprintf(out, n, "%s", dir); @@ -92,10 +96,10 @@ void config_load(Config *c) GetVersionEx(&v); bool old = v.dwPlatformId != VER_PLATFORM_WIN32_NT || v.dwMajorVersion < 6; #ifdef DMODEM_WINPORT - /* (Linux and macOS, winport/: no COM ports or dmodemd started by the - app yet, so a dmodemd that runs, through TCP) */ + /* (Linux and macOS, winport/: dmodemd runs there, whatever Windows + version the layer reports) */ (void)old; - c->line = get_i(ini, "line", LINE_TCP); + c->line = get_i(ini, "line", LINE_DMODEMD); #else #ifdef DMODEM_GUI_EMBED /* (the modem built in runs on Windows 98 SE and later) */ diff --git a/windows/src/link.cpp b/windows/src/link.cpp index 4d8f54a..7bc8862 100644 --- a/windows/src/link.cpp +++ b/windows/src/link.cpp @@ -213,7 +213,7 @@ static bool open_com(const char *name) return true; } -/* dmodemd.exe: the configured one, or next to this app */ +/* dmodemd: the configured one, or next to this app */ static void dmodemd_path(char *out, int n) { if (app.cfg.dmodemd[0]) { @@ -222,9 +222,17 @@ static void dmodemd_path(char *out, int n) return; } GetModuleFileName(NULL, out, n); - char *slash = strrchr(out, '\\'); + char *slash = strrchr(out, DIR_SEP[0]); if (slash) - strcpy(slash + 1, "dmodemd.exe"); + strcpy(slash + 1, DMODEMD_EXE); +#ifdef DMODEM_WINPORT + /* (Linux and macOS, winport/: else the one on the PATH) */ + char found[MAX_PATH]; + if (GetFileAttributes(out) == (DWORD)-1 && + SearchPath(NULL, DMODEMD_EXE, NULL, sizeof(found), found, NULL)) + _snprintf(out, n, "%s", found); + out[n - 1] = '\0'; +#endif } /* an environment block: ours, and these */ @@ -272,7 +280,7 @@ static bool start_dmodemd() dmodemd_path(exe, sizeof(exe)); if (GetFileAttributes(exe) == (DWORD)-1) { char m[MAX_PATH + 64]; - _snprintf(m, sizeof(m), "dmodemd.exe was not found (%s)", exe); + _snprintf(m, sizeof(m), DMODEMD_EXE " was not found (%s)", exe); m[sizeof(m) - 1] = '\0'; app_message(m); app_log(m); diff --git a/windows/src/main.cpp b/windows/src/main.cpp index e57eee5..2b2506d 100644 --- a/windows/src/main.cpp +++ b/windows/src/main.cpp @@ -209,22 +209,36 @@ void app_event(const dmc_event *ev) } } -#ifdef DMODEM_WINPORT -/* (Linux and macOS, winport/: the layer's hit test stops at a group box, - which answers HTTRANSPARENT, and does not try the controls under it. - Windows tries them. Until the layer does too, put the group boxes - under the other controls.) */ -static BOOL CALLBACK lower_group_box(HWND c, LPARAM lp) +/* a page's labels (static controls) and group boxes under its other + controls, and clipped by them (WS_CLIPSIBLINGS): a label paints all of + its rectangle, and without this it paints over a control that it + overlaps. The group boxes go lowest. (Only the pages: in a dialog box, + a label's mnemonic goes to the control after it in this order.) */ +static void lower_labels(HWND page) { - char cls[16]; - (void)lp; - if (GetClassName(c, cls, sizeof(cls)) && !lstrcmpi(cls, "BUTTON") && - (GetWindowLong(c, GWL_STYLE) & BS_TYPEMASK) == BS_GROUPBOX) - SetWindowPos(c, HWND_BOTTOM, 0, 0, 0, 0, - SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); - return TRUE; + HWND kids[128]; + int n = 0; + for (HWND c = GetWindow(page, GW_CHILD); c && n < 128; + c = GetWindow(c, GW_HWNDNEXT)) + kids[n++] = c; + for (int pass = 0; pass < 2; pass++) { + for (int i = 0; i < n; i++) { + char cls[16]; + if (!GetClassName(kids[i], cls, sizeof(cls))) + continue; + LONG st = GetWindowLong(kids[i], GWL_STYLE); + bool group = !lstrcmpi(cls, "BUTTON") && + (st & BS_TYPEMASK) == BS_GROUPBOX; + bool label = !lstrcmpi(cls, "STATIC"); + if (pass == 0 ? !label : !group) + continue; + SetWindowLong(kids[i], GWL_STYLE, st | WS_CLIPSIBLINGS); + SetWindowPos(kids[i], HWND_BOTTOM, 0, 0, 0, 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | + SWP_FRAMECHANGED); + } + } } -#endif static int page_now; @@ -323,18 +337,33 @@ static LRESULT CALLBACK main_proc(HWND w, UINT m, WPARAM wp, LPARAM lp) app.pages[PAGE_SETTINGS] = settings_page_new(w); app.pages[PAGE_STATS] = stats_page_new(w); app.pages[PAGE_LOG] = log_page_new(w); - for (int p = 0; p < PAGES; p++) + for (int p = 0; p < PAGES; p++) { SetWindowPos(app.pages[p], HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); -#ifdef DMODEM_WINPORT - for (int p = 0; p < PAGES; p++) - EnumChildWindows(app.pages[p], lower_group_box, 0); -#endif + lower_labels(app.pages[p]); + } show_page(PAGE_MODEM); SetTimer(w, TIMER_PUMP, 50, NULL); app_state(); return 0; } + case WM_ACTIVATE: { + /* the control with the focus kept while another window (a + dialog box) is active, and given back after: the default + gives the focus to this window */ + static HWND last_focus; + if (LOWORD(wp) == WA_INACTIVE) { + HWND f = GetFocus(); + if (f && IsChild(w, f)) + last_focus = f; + } else if (last_focus && IsWindow(last_focus) && + IsWindowVisible(last_focus) && + IsWindowEnabled(last_focus)) { + SetFocus(last_focus); + return 0; + } + break; + } case WM_SIZE: layout(); return 0; diff --git a/windows/src/pathview.cpp b/windows/src/pathview.cpp index c1e2c59..0ebaa78 100644 --- a/windows/src/pathview.cpp +++ b/windows/src/pathview.cpp @@ -53,21 +53,6 @@ static const char *mark(int kind, bool *wingdings) } } -#ifdef DMODEM_WINPORT -/* (Linux and macOS, winport/: no Wingdings there; the same pictures from - Unicode, in a font that the system has) */ -static const wchar_t *mark_w(const char *m) -{ - switch (m[0]) { - case ':': return L"\x2328"; /* a keyboard */ - case ';': return L"\x25A3"; /* a box */ - case ')': return L"\x260E"; /* a telephone */ - case '*': return L"\x2709"; /* an envelope */ - default: return L"\x260F"; /* a telephone, white */ - } -} -#endif - static void line(HDC dc, int st, int x0, int x1, int y) { bool dashed = st == DMC_STEP_SETUP || st == DMC_STEP_OFF; @@ -133,12 +118,6 @@ static void paint(HWND w) RECT g = { cx - r, cy - r, cx + r, cy + r }; SelectObject(dc, wd ? glyph_font : app.font); SetTextColor(dc, state_color(st)); -#ifdef DMODEM_WINPORT - if (wd) - DrawTextW(dc, mark_w(m), -1, &g, DT_CENTER | DT_VCENTER | - DT_SINGLELINE | DT_NOPREFIX); - else -#endif DrawText(dc, m, -1, &g, DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX); RECT tt = { x, cy + r + 4, x + cw, cy + r + 4 + th }; @@ -185,12 +164,8 @@ HWND pathview_new(HWND parent) LOGFONT lf; memset(&lf, 0, sizeof(lf)); lf.lfHeight = -20; -#ifdef DMODEM_WINPORT - strcpy(lf.lfFaceName, "DejaVu Sans"); -#else lf.lfCharSet = SYMBOL_CHARSET; strcpy(lf.lfFaceName, "Wingdings"); -#endif glyph_font = CreateFontIndirect(&lf); } path = dmc_path_new(); diff --git a/winport/CMakeLists.txt b/winport/CMakeLists.txt index a1dd663..64fcbfe 100644 --- a/winport/CMakeLists.txt +++ b/winport/CMakeLists.txt @@ -3,12 +3,6 @@ # # cmake -B build -DDMODEM_GUI_WINPORT=ON -DCLANG_RETRO_MFC=/path/to/mfc \ # -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -# -# This is a first pass. The layer does not have serial ports, pipes or -# audio (waveOut, waveIn and ACM) yet. The files in include/ and -# src/stubs.cpp supply stand-ins: these functions fail, so the app uses -# the TCP and SSH links only. When the layer gets these functions, -# remove the stand-ins. enable_language(CXX) if(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang") @@ -64,10 +58,7 @@ set(APP_RES_CPP "${CMAKE_CURRENT_BINARY_DIR}/app-res.cpp") add_custom_command(OUTPUT "${APP_RES_CPP}" COMMAND ${CMAKE_COMMAND} -E env RC=${DMODEM_LLVM_RC} CXX=${CMAKE_CXX_COMPILER} ${Python3_EXECUTABLE} "${CLANG_RETRO_MFC}/port/tools/res2cpp.py" - -I "${_win}/src" -I "${_win}/res" app.rc -o "${APP_RES_CPP}" - # (app.rc by a relative path: llvm-rc takes an absolute macOS path, - # /Users/..., for an option) - WORKING_DIRECTORY "${_win}/res" + -I "${_win}/src" -I "${_win}/res" "${_win}/res/app.rc" -o "${APP_RES_CPP}" DEPENDS "${_win}/res/app.rc" "${_win}/res/app.manifest" "${_win}/res/dmodem.ico" "${_win}/src/resource.h" COMMENT "Converting app.rc to C++" @@ -76,12 +67,10 @@ add_custom_command(OUTPUT "${APP_RES_CPP}" include("${_win}/sources.cmake") add_executable(dmodem-win32 ${DMODEM_WIN_SOURCES} - src/stubs.cpp "${APP_RES_CPP}") set_target_properties(dmodem-win32 PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON) -# Our stand-in headers come first, then the layer's headers. target_include_directories(dmodem-win32 BEFORE PRIVATE - include "${CLANG_RETRO_MFC}/port/include" "${_win}/src" "${_win}/res") + "${CLANG_RETRO_MFC}/port/include" "${_win}/src" "${_win}/res") target_compile_definitions(dmodem-win32 PRIVATE DMODEM_WINPORT) target_compile_options(dmodem-win32 PRIVATE -Wall -Wno-unused-parameter) target_link_libraries(dmodem-win32 PRIVATE dmodemctl winport) diff --git a/winport/include/commctrl.h b/winport/include/commctrl.h deleted file mode 100644 index 563422a..0000000 --- a/winport/include/commctrl.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * SPDX-License-Identifier: AGPL-3.0-only - * Copyright (C) 2026 D-Modem Authors - * - * commctrl.h - the common controls of the Win32 layer (clang-retro MFC's - * port/), with the helper macros of the SDK that the app - * uses and the layer does not have yet. ( first: - * the layer's commctrl.h needs LPSTREAM, which its - * gives only without WIN32_LEAN_AND_MEAN.) - */ -#ifndef DMODEM_WINPORT_COMMCTRL_H -#define DMODEM_WINPORT_COMMCTRL_H -#include -#include -#include_next - -#ifndef ListView_InsertColumn -#define ListView_InsertColumn(w, i, c) \ - (int)SendMessage((w), LVM_INSERTCOLUMN, (WPARAM)(int)(i), (LPARAM)(c)) -#endif -#ifndef ListView_InsertItem -#define ListView_InsertItem(w, item) \ - (int)SendMessage((w), LVM_INSERTITEM, 0, (LPARAM)(item)) -#endif -#ifndef ListView_GetItem -#define ListView_GetItem(w, item) \ - (BOOL)SendMessage((w), LVM_GETITEM, 0, (LPARAM)(item)) -#endif -#ifndef ListView_DeleteAllItems -#define ListView_DeleteAllItems(w) \ - (BOOL)SendMessage((w), LVM_DELETEALLITEMS, 0, 0) -#endif -#ifndef ListView_GetNextItem -#define ListView_GetNextItem(w, i, flags) \ - (int)SendMessage((w), LVM_GETNEXTITEM, (WPARAM)(int)(i), \ - MAKELPARAM((flags), 0)) -#endif -#ifndef ListView_SetExtendedListViewStyle -#define ListView_SetExtendedListViewStyle(w, ex) \ - (DWORD)SendMessage((w), LVM_SETEXTENDEDLISTVIEWSTYLE, 0, (LPARAM)(ex)) -#endif -#ifndef ListView_SetItemText -#define ListView_SetItemText(w, i, sub, text) \ - do { \ - LV_ITEM lvi_; \ - lvi_.iSubItem = (sub); \ - lvi_.pszText = (text); \ - SendMessage((w), LVM_SETITEMTEXT, (WPARAM)(i), \ - (LPARAM)&lvi_); \ - } while (0) -#endif -#ifndef TabCtrl_InsertItem -#define TabCtrl_InsertItem(w, i, item) \ - (int)SendMessage((w), TCM_INSERTITEM, (WPARAM)(int)(i), (LPARAM)(item)) -#endif -#ifndef TabCtrl_GetCurSel -#define TabCtrl_GetCurSel(w) (int)SendMessage((w), TCM_GETCURSEL, 0, 0) -#endif -#ifndef TabCtrl_AdjustRect -#define TabCtrl_AdjustRect(w, larger, rc) \ - (void)SendMessage((w), TCM_ADJUSTRECT, (WPARAM)(BOOL)(larger), (LPARAM)(rc)) -#endif -#endif diff --git a/winport/include/mmreg.h b/winport/include/mmreg.h deleted file mode 100644 index 1bea048..0000000 --- a/winport/include/mmreg.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * SPDX-License-Identifier: AGPL-3.0-only - * Copyright (C) 2026 D-Modem Authors - * - * mmreg.h - the MP3 format of the ACM, as the app's audio.cpp names it - */ -#ifndef DMODEM_WINPORT_MMREG_H -#define DMODEM_WINPORT_MMREG_H -#include - -#define WAVE_FORMAT_MPEGLAYER3 0x0055 -#define MPEGLAYER3_WFX_EXTRA_BYTES 12 -#define MPEGLAYER3_ID_MPEG 1 -#define MPEGLAYER3_FLAG_PADDING_OFF 0x00000002 - -#pragma pack(push, 1) -typedef struct mpeglayer3waveformat_tag { - WAVEFORMATEX wfx; - WORD wID; - DWORD fdwFlags; - WORD nBlockSize; - WORD nFramesPerBlock; - WORD nCodecDelay; -} MPEGLAYER3WAVEFORMAT, *LPMPEGLAYER3WAVEFORMAT; -#pragma pack(pop) -#endif diff --git a/winport/include/mmsystem.h b/winport/include/mmsystem.h deleted file mode 100644 index 29a8ee1..0000000 --- a/winport/include/mmsystem.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * SPDX-License-Identifier: AGPL-3.0-only - * Copyright (C) 2026 D-Modem Authors - * - * mmsystem.h - the part of the multimedia API that the app's sound - * (audio.cpp, voice.cpp) uses, which the Win32 layer does not - * have. First pass: the functions are in src/stubs.cpp and - * answer MMSYSERR_NODRIVER (no sound device). - */ -#ifndef DMODEM_WINPORT_MMSYSTEM_H -#define DMODEM_WINPORT_MMSYSTEM_H -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef UINT MMRESULT; -typedef struct dmodem_hwaveout *HWAVEOUT; -typedef struct dmodem_hwavein *HWAVEIN; - -#define MMSYSERR_NOERROR 0 -#define MMSYSERR_ERROR 1 -#define MMSYSERR_BADDEVICEID 2 -#define MMSYSERR_NODRIVER 6 -#define WAVE_MAPPER ((UINT)-1) -#define CALLBACK_WINDOW 0x00010000L -#define MM_WOM_DONE 0x3BD -#define MM_WIM_DATA 0x3C0 -#define WHDR_DONE 0x00000001 -#define WHDR_PREPARED 0x00000002 -#define WAVE_FORMAT_PCM 1 - -#pragma pack(push, 1) -typedef struct tWAVEFORMATEX { - WORD wFormatTag; - WORD nChannels; - DWORD nSamplesPerSec; - DWORD nAvgBytesPerSec; - WORD nBlockAlign; - WORD wBitsPerSample; - WORD cbSize; -} WAVEFORMATEX, *PWAVEFORMATEX, *LPWAVEFORMATEX; -#pragma pack(pop) -typedef const WAVEFORMATEX *LPCWAVEFORMATEX; - -typedef struct wavehdr_tag { - LPSTR lpData; - DWORD dwBufferLength; - DWORD dwBytesRecorded; - DWORD_PTR dwUser; - DWORD dwFlags; - DWORD dwLoops; - struct wavehdr_tag *lpNext; - DWORD_PTR reserved; -} WAVEHDR, *PWAVEHDR, *LPWAVEHDR; - -MMRESULT WINAPI waveOutOpen(HWAVEOUT *, UINT, LPCWAVEFORMATEX, DWORD_PTR, - DWORD_PTR, DWORD); -MMRESULT WINAPI waveOutClose(HWAVEOUT); -MMRESULT WINAPI waveOutPrepareHeader(HWAVEOUT, LPWAVEHDR, UINT); -MMRESULT WINAPI waveOutUnprepareHeader(HWAVEOUT, LPWAVEHDR, UINT); -MMRESULT WINAPI waveOutWrite(HWAVEOUT, LPWAVEHDR, UINT); -MMRESULT WINAPI waveOutReset(HWAVEOUT); -MMRESULT WINAPI waveInOpen(HWAVEIN *, UINT, LPCWAVEFORMATEX, DWORD_PTR, - DWORD_PTR, DWORD); -MMRESULT WINAPI waveInClose(HWAVEIN); -MMRESULT WINAPI waveInPrepareHeader(HWAVEIN, LPWAVEHDR, UINT); -MMRESULT WINAPI waveInUnprepareHeader(HWAVEIN, LPWAVEHDR, UINT); -MMRESULT WINAPI waveInAddBuffer(HWAVEIN, LPWAVEHDR, UINT); -MMRESULT WINAPI waveInStart(HWAVEIN); -MMRESULT WINAPI waveInReset(HWAVEIN); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/winport/include/msacm.h b/winport/include/msacm.h deleted file mode 100644 index 00cc63c..0000000 --- a/winport/include/msacm.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SPDX-License-Identifier: AGPL-3.0-only - * Copyright (C) 2026 D-Modem Authors - * - * msacm.h - the Audio Compression Manager calls that the app's audio.cpp - * uses (greetings in MP3 and compressed WAVs). First pass: the - * functions are in src/stubs.cpp and answer MMSYSERR_NODRIVER, - * so the app reads only the files that libdmodemctl decodes. - */ -#ifndef DMODEM_WINPORT_MSACM_H -#define DMODEM_WINPORT_MSACM_H -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct dmodem_hacmstream *HACMSTREAM; -typedef HACMSTREAM *LPHACMSTREAM; -typedef struct dmodem_hacmdriver *HACMDRIVER; - -#define ACM_FORMATSUGGESTF_WFORMATTAG 0x00010000L -#define ACM_FORMATSUGGESTF_NCHANNELS 0x00020000L -#define ACM_FORMATSUGGESTF_NSAMPLESPERSEC 0x00040000L -#define ACM_FORMATSUGGESTF_WBITSPERSAMPLE 0x00080000L -#define ACM_STREAMOPENF_NONREALTIME 0x00000004L -#define ACM_STREAMSIZEF_SOURCE 0x00000000L -#define ACM_STREAMCONVERTF_BLOCKALIGN 0x00000004 -#define ACM_STREAMCONVERTF_START 0x00000010 -#define ACM_STREAMCONVERTF_END 0x00000020 - -typedef struct tACMSTREAMHEADER { - DWORD cbStruct; - DWORD fdwStatus; - DWORD_PTR dwUser; - LPBYTE pbSrc; - DWORD cbSrcLength; - DWORD cbSrcLengthUsed; - DWORD_PTR dwSrcUser; - LPBYTE pbDst; - DWORD cbDstLength; - DWORD cbDstLengthUsed; - DWORD_PTR dwDstUser; - DWORD dwReservedDriver[10]; -} ACMSTREAMHEADER, *LPACMSTREAMHEADER; - -MMRESULT WINAPI acmFormatSuggest(HACMDRIVER, LPWAVEFORMATEX, LPWAVEFORMATEX, - DWORD, DWORD); -MMRESULT WINAPI acmStreamOpen(LPHACMSTREAM, HACMDRIVER, LPWAVEFORMATEX, - LPWAVEFORMATEX, LPVOID, DWORD_PTR, DWORD_PTR, - DWORD); -MMRESULT WINAPI acmStreamClose(HACMSTREAM, DWORD); -MMRESULT WINAPI acmStreamSize(HACMSTREAM, DWORD, LPDWORD, DWORD); -MMRESULT WINAPI acmStreamPrepareHeader(HACMSTREAM, LPACMSTREAMHEADER, DWORD); -MMRESULT WINAPI acmStreamUnprepareHeader(HACMSTREAM, LPACMSTREAMHEADER, - DWORD); -MMRESULT WINAPI acmStreamConvert(HACMSTREAM, LPACMSTREAMHEADER, DWORD); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/winport/include/windows.h b/winport/include/windows.h deleted file mode 100644 index 3452e2e..0000000 --- a/winport/include/windows.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * SPDX-License-Identifier: AGPL-3.0-only - * Copyright (C) 2026 D-Modem Authors - * - * windows.h - the Win32 layer of clang-retro MFC (port/), and the calls of - * the app that it does not have yet: serial ports, anonymous - * pipes, the environment block, the user name, Beep and - * the declaration of WinMain. - * First pass: src/stubs.cpp has them. The serial and pipe - * calls fail, so the app reaches a modem through TCP only. - */ -#ifndef DMODEM_WINPORT_WINDOWS_H -#define DMODEM_WINPORT_WINDOWS_H -#include_next - -#ifdef __cplusplus -extern "C" { -#endif - -/* (the SDK's winbase.h declares it, with C linkage; the layer's crt0 - calls it) */ -int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int); - -/* (newer layers have the serial ports, the pipes, the environment, the - user and Beep themselves: CBR_115200 is theirs then) */ -#ifdef CBR_115200 -#define DMODEM_WINPORT_LAYER_KERNEL 1 -#else -/* serial ports */ -#define CBR_115200 115200 -#define NOPARITY 0 -#define ONESTOPBIT 0 -#define DTR_CONTROL_ENABLE 0x01 -#define RTS_CONTROL_HANDSHAKE 0x02 - -typedef struct _DCB { - DWORD DCBlength; - DWORD BaudRate; - DWORD fBinary : 1; - DWORD fParity : 1; - DWORD fOutxCtsFlow : 1; - DWORD fOutxDsrFlow : 1; - DWORD fDtrControl : 2; - DWORD fDsrSensitivity : 1; - DWORD fTXContinueOnXoff : 1; - DWORD fOutX : 1; - DWORD fInX : 1; - DWORD fErrorChar : 1; - DWORD fNull : 1; - DWORD fRtsControl : 2; - DWORD fAbortOnError : 1; - DWORD fDummy2 : 17; - WORD wReserved; - WORD XonLim; - WORD XoffLim; - BYTE ByteSize; - BYTE Parity; - BYTE StopBits; - char XonChar; - char XoffChar; - char ErrorChar; - char EofChar; - char EvtChar; - WORD wReserved1; -} DCB, *LPDCB; - -typedef struct _COMMTIMEOUTS { - DWORD ReadIntervalTimeout; - DWORD ReadTotalTimeoutMultiplier; - DWORD ReadTotalTimeoutConstant; - DWORD WriteTotalTimeoutMultiplier; - DWORD WriteTotalTimeoutConstant; -} COMMTIMEOUTS, *LPCOMMTIMEOUTS; - -BOOL WINAPI GetCommState(HANDLE, LPDCB); -BOOL WINAPI SetCommState(HANDLE, LPDCB); -BOOL WINAPI SetCommTimeouts(HANDLE, LPCOMMTIMEOUTS); -BOOL WINAPI SetCommBreak(HANDLE); -BOOL WINAPI ClearCommBreak(HANDLE); - -/* anonymous pipes */ -BOOL WINAPI CreatePipe(PHANDLE, PHANDLE, LPSECURITY_ATTRIBUTES, DWORD); -BOOL WINAPI PeekNamedPipe(HANDLE, LPVOID, DWORD, LPDWORD, LPDWORD, LPDWORD); - -/* the environment, the user, the speaker */ -LPSTR WINAPI dmodem_GetEnvironmentStringsA(void); -BOOL WINAPI dmodem_FreeEnvironmentStringsA(LPSTR); -#define GetEnvironmentStrings dmodem_GetEnvironmentStringsA -#define FreeEnvironmentStrings dmodem_FreeEnvironmentStringsA -BOOL WINAPI GetUserNameA(LPSTR, LPDWORD); -#ifndef UNICODE -#define GetUserName GetUserNameA -#endif -BOOL WINAPI Beep(DWORD, DWORD); -#endif - -#ifdef __cplusplus -} -#endif -#endif diff --git a/winport/include/winsock.h b/winport/include/winsock.h deleted file mode 100644 index a423416..0000000 --- a/winport/include/winsock.h +++ /dev/null @@ -1,3 +0,0 @@ -/* winsock.h - Winsock 1.1: the Win32 layer has the Winsock 2 header, - which has each function of 1.1 */ -#include diff --git a/winport/src/stubs.cpp b/winport/src/stubs.cpp deleted file mode 100644 index 37b8962..0000000 --- a/winport/src/stubs.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/* - * SPDX-License-Identifier: AGPL-3.0-only - * Copyright (C) 2026 D-Modem Authors - * - * stubs.cpp - the Win32 calls of the app that the Win32 layer of - * clang-retro MFC does not have yet (include/). First pass: - * the sound, ACM, serial and pipe calls fail, so the app - * operates through TCP (a dmodemd that already runs) and - * SSH, Telnet and rlogin. Remove each one when the layer - * has it. - */ -#include -#include -#include - -#include -#include -#include - -extern char **environ; - -extern "C" { - -/* sound: no device */ -MMRESULT WINAPI waveOutOpen(HWAVEOUT *, UINT, LPCWAVEFORMATEX, DWORD_PTR, - DWORD_PTR, DWORD) { return MMSYSERR_NODRIVER; } -MMRESULT WINAPI waveOutClose(HWAVEOUT) { return MMSYSERR_NODRIVER; } -MMRESULT WINAPI waveOutPrepareHeader(HWAVEOUT, LPWAVEHDR, UINT) { return MMSYSERR_NODRIVER; } -MMRESULT WINAPI waveOutUnprepareHeader(HWAVEOUT, LPWAVEHDR, UINT) { return MMSYSERR_NODRIVER; } -MMRESULT WINAPI waveOutWrite(HWAVEOUT, LPWAVEHDR, UINT) { return MMSYSERR_NODRIVER; } -MMRESULT WINAPI waveOutReset(HWAVEOUT) { return MMSYSERR_NODRIVER; } -MMRESULT WINAPI waveInOpen(HWAVEIN *, UINT, LPCWAVEFORMATEX, DWORD_PTR, - DWORD_PTR, DWORD) { return MMSYSERR_NODRIVER; } -MMRESULT WINAPI waveInClose(HWAVEIN) { return MMSYSERR_NODRIVER; } -MMRESULT WINAPI waveInPrepareHeader(HWAVEIN, LPWAVEHDR, UINT) { return MMSYSERR_NODRIVER; } -MMRESULT WINAPI waveInUnprepareHeader(HWAVEIN, LPWAVEHDR, UINT) { return MMSYSERR_NODRIVER; } -MMRESULT WINAPI waveInAddBuffer(HWAVEIN, LPWAVEHDR, UINT) { return MMSYSERR_NODRIVER; } -MMRESULT WINAPI waveInStart(HWAVEIN) { return MMSYSERR_NODRIVER; } -MMRESULT WINAPI waveInReset(HWAVEIN) { return MMSYSERR_NODRIVER; } - -/* ACM: no codecs */ -MMRESULT WINAPI acmFormatSuggest(HACMDRIVER, LPWAVEFORMATEX, LPWAVEFORMATEX, - DWORD, DWORD) { return MMSYSERR_NODRIVER; } -MMRESULT WINAPI acmStreamOpen(LPHACMSTREAM, HACMDRIVER, LPWAVEFORMATEX, - LPWAVEFORMATEX, LPVOID, DWORD_PTR, DWORD_PTR, - DWORD) { return MMSYSERR_NODRIVER; } -MMRESULT WINAPI acmStreamClose(HACMSTREAM, DWORD) { return MMSYSERR_NODRIVER; } -MMRESULT WINAPI acmStreamSize(HACMSTREAM, DWORD, LPDWORD, DWORD) { return MMSYSERR_NODRIVER; } -MMRESULT WINAPI acmStreamPrepareHeader(HACMSTREAM, LPACMSTREAMHEADER, DWORD) { return MMSYSERR_NODRIVER; } -MMRESULT WINAPI acmStreamUnprepareHeader(HACMSTREAM, LPACMSTREAMHEADER, DWORD) { return MMSYSERR_NODRIVER; } -MMRESULT WINAPI acmStreamConvert(HACMSTREAM, LPACMSTREAMHEADER, DWORD) { return MMSYSERR_NODRIVER; } - -#ifndef DMODEM_WINPORT_LAYER_KERNEL -/* serial ports: none */ -BOOL WINAPI GetCommState(HANDLE, LPDCB) -{ - SetLastError(ERROR_NOT_SUPPORTED); - return FALSE; -} -BOOL WINAPI SetCommState(HANDLE, LPDCB) -{ - SetLastError(ERROR_NOT_SUPPORTED); - return FALSE; -} -BOOL WINAPI SetCommTimeouts(HANDLE, LPCOMMTIMEOUTS) -{ - SetLastError(ERROR_NOT_SUPPORTED); - return FALSE; -} -BOOL WINAPI SetCommBreak(HANDLE) -{ - SetLastError(ERROR_NOT_SUPPORTED); - return FALSE; -} -BOOL WINAPI ClearCommBreak(HANDLE) -{ - SetLastError(ERROR_NOT_SUPPORTED); - return FALSE; -} - -/* anonymous pipes: none (no dmodemd started by the app) */ -BOOL WINAPI CreatePipe(PHANDLE, PHANDLE, LPSECURITY_ATTRIBUTES, DWORD) -{ - SetLastError(ERROR_NOT_SUPPORTED); - return FALSE; -} -BOOL WINAPI PeekNamedPipe(HANDLE, LPVOID, DWORD, LPDWORD, LPDWORD, LPDWORD) -{ - SetLastError(ERROR_NOT_SUPPORTED); - return FALSE; -} - -/* the environment block of Windows (NAME=VALUE\0 ... \0) from environ */ -LPSTR WINAPI dmodem_GetEnvironmentStringsA(void) -{ - size_t n = 1; - for (char **e = environ; *e; e++) - n += strlen(*e) + 1; - char *block = (char *)malloc(n), *p = block; - if (!block) - return NULL; - for (char **e = environ; *e; e++) { - size_t l = strlen(*e) + 1; - memcpy(p, *e, l); - p += l; - } - *p = '\0'; - return block; -} -BOOL WINAPI dmodem_FreeEnvironmentStringsA(LPSTR block) -{ - free(block); - return TRUE; -} - -BOOL WINAPI GetUserNameA(LPSTR name, LPDWORD n) -{ - const char *u = getenv("USER"); - if (!u) - u = getlogin(); - if (!u || strlen(u) + 1 > *n) { - SetLastError(ERROR_INSUFFICIENT_BUFFER); - return FALSE; - } - strcpy(name, u); - *n = (DWORD)strlen(u) + 1; - return TRUE; -} - -/* (no speaker: the terminal's bell is MessageBeep) */ -BOOL WINAPI Beep(DWORD, DWORD) -{ - MessageBeep(MB_OK); - return TRUE; -} - -#endif - -} diff --git a/winport/test/dmodemd b/winport/test/dmodemd new file mode 100755 index 0000000..ffb9f92 --- /dev/null +++ b/winport/test/dmodemd @@ -0,0 +1,8 @@ +#!/bin/sh +# A dmodemd for the smoke test: it takes --tcp HOST:PORT, says which +# port to use as dmodemd does, and starts the test modem on that port. +here=$(cd "$(dirname "$0")" && pwd) +port=$(echo "$*" | sed -n 's/.*--tcp [0-9.]*:\([0-9]*\).*/\1/p') +echo "test dmodemd: $*" +(sleep 1; echo "Use TCP 127.0.0.1:$port as the modem") & +exec python3 -u "$here/fake_modem.py" "$port" "$DMODEM_TEST_LOG" diff --git a/winport/test/smoke.sh b/winport/test/smoke.sh index 721c962..a5aacfa 100755 --- a/winport/test/smoke.sh +++ b/winport/test/smoke.sh @@ -1,32 +1,52 @@ #!/bin/sh -# The smoke test of the Linux build (winport/): starts the app on an X -# display with an empty home folder, and makes sure that it stays up and -# sends its first AT commands to a test modem on the TCP port that it -# uses by default (127.0.0.1:2323). +# The smoke test of the Linux build (winport/). It starts the app on an +# X display, with an empty home folder, two times: +# 1. With a TCP line (127.0.0.1:2323) to a test modem. +# 2. With a dmodemd that the app starts: the test dmodemd in this +# folder, found on the PATH, through a pipe (CreatePipe, +# CreateProcess with STARTF_USESTDHANDLES and PeekNamedPipe). +# Each time, the app must stay up and send its first AT commands. # # DISPLAY=:99 winport/test/smoke.sh build/winport/dmodem-win32 set -eu app=$1 here=$(cd "$(dirname "$0")" && pwd) tmp=$(mktemp -d) -trap 'kill $modem $pid 2>/dev/null || true; rm -rf "$tmp"' EXIT +pid= modem= +trap 'kill $modem $pid 2>/dev/null || true; pkill -f "fake_modem.py .* $tmp/" 2>/dev/null || true; rm -rf "$tmp"' EXIT -python3 "$here/fake_modem.py" 2323 "$tmp/modem.log" & +# run NAME INI: starts the app with this settings file, and waits for AT +# commands in $tmp/NAME.log +run() { + name=$1 + rm -rf "$tmp/home" + mkdir -p "$tmp/home/.config/D-Modem" + printf '%b' "$2" > "$tmp/home/.config/D-Modem/dmodem.ini" + HOME="$tmp/home" XDG_CONFIG_HOME= PATH="$here:$PATH" \ + DMODEM_TEST_LOG="$tmp/$name.log" WINPORT_BACKEND=x11 "$app" & + pid=$! + i=0 + while [ $i -lt 20 ]; do + sleep 1 + kill -0 $pid 2>/dev/null || { echo "FAIL ($name): the app stopped"; exit 1; } + grep -q '^AT' "$tmp/$name.log" 2>/dev/null && break + i=$((i + 1)) + done + grep -q '^AT' "$tmp/$name.log" 2>/dev/null || + { echo "FAIL ($name): no AT commands"; exit 1; } + sleep 2 + kill -0 $pid 2>/dev/null || { echo "FAIL ($name): the app stopped"; exit 1; } + echo "$name: the modem got:" + cat "$tmp/$name.log" + kill $pid + wait $pid 2>/dev/null || true + pid= +} + +python3 "$here/fake_modem.py" 2323 "$tmp/tcp.log" & modem=$! sleep 1 -HOME="$tmp/home" WINPORT_BACKEND=x11 "$app" & -pid=$! - -i=0 -while [ $i -lt 20 ]; do - sleep 1 - kill -0 $pid 2>/dev/null || { echo "FAIL: the app stopped"; exit 1; } - grep -q '^AT' "$tmp/modem.log" 2>/dev/null && break - i=$((i + 1)) -done -grep -q '^AT' "$tmp/modem.log" || { echo "FAIL: no AT commands on the TCP port"; exit 1; } -sleep 2 -kill -0 $pid 2>/dev/null || { echo "FAIL: the app stopped"; exit 1; } -echo "The modem got:" -cat "$tmp/modem.log" +run tcp '[line]\nline=1\ntcp=127.0.0.1:2323\n' +# (a USB modem: dmodemd needs no SIP account for it) +run dmodemd '[line]\nline=0\nusb=test0\n' echo "PASS"