18 Commits
Author SHA1 Message Date
lotherk 4774c2c7d8 dtchat: verify adapter files whose hash arrives at the end (T4.5)
Telegram and WhatsApp learn a document's SHA-256 only when the transfer is
finished, so their file-offer carries none and the digest comes with
file-end.  The UI used to verify only the offer hash, which meant those two
paths wrote the bytes unchecked.  accounts_run now takes the offer's hash
when there is one and the file-end's otherwise, hashes the .part file after
the last chunk and renames only on a match; a mismatch still removes the
part file and reports it in the status line and the transcript.

The fake adapter gained the matching modes: latehash offers without a hash
and sends the right one in file-end, badendhash sends a wrong one there.
tests/file_ui.sh drives all four shapes through the real UI under its own
Xvfb with DTCHAT_TEST_FILE_ACCEPT: files and latehash write the verified
hello world, badhash and badendhash are rejected and leave neither the file
nor a .part.  Measured with the built binaries: four ok, exit 0.

Harness entry DtChat/file_ui added; the full run is 53 ok/0 bad
(make mcde-host exit=0, build/logs/mcde-host-2026-11-17-endhash.log).
2026-11-17 13:08:55 +00:00
lotherk 63fedd905a dtchat: test the packaged adapter layout (T10.8)
tests/packaged_layout.sh starts dtchat under a private Xvfb with one account
whose "adapter" field is empty.  The runtime has to resolve
<dir of dtchat>/dtchat-telegram and start it; DTCHAT_TELEGRAM_FAKE=1 makes
the adapter speak without an account, and DTCHAT_ACCOUNTS_DEBUG logs the
resolved path.  The test accepts both layouts: the libtool build (the
wrapper in programs/dtchat starts the real binary from .libs, where the
adapter sits) and the installed prefix (build/mcde-root/dt/bin), and it
matches the path the runtime actually logged instead of assuming one.

Measured: the libtool layout started
build/mcde-host/programs/dtchat/.libs/dtchat-telegram, the installed prefix
started build/mcde-root/dt/bin/dtchat-telegram, both from an empty adapter
field, and the adapter answered with its connecting state; all ok.  The
test uses its own display number so it can run beside other Xvfb sessions.
Harness entry DtChat/packaged_layout added (52 entries).
2026-11-17 13:04:08 +00:00
lotherk 056bd30a8f dtchat: exercise WhatsApp incoming files with a real fake file (T9.1)
DTCHAT_WHATSAPP_FAKE_FILE makes the fake adapter offer that file (name, size, SHA-256), and on file-accept read it in 4 KiB blocks, emit file-data and a file-end carrying the hash; the real accept path (DownloadAny) now also sends the SHA-256 in file-end, and the static fake keeps its hello-world hash. tests/whatsapp_fake.py uses a 9000-byte deterministic file, checks the offer name/size/hash, reassembles every chunk byte-for-byte and verifies the file-end hash (31 checks, green stand-alone). Harness entry already exists; in-tree build and harness follow.
2026-11-17 12:29:27 +00:00
lotherk 790669d989 dtchat: download accepted Telegram documents (T8.1)
An incoming messageDocument is remembered with its TDLib file id; file-accept sends downloadFile (priority 1, whole file) and updateFile is followed until local.is_downloading_completed, then the local file is read in 4 KiB blocks and sent as file-data with a file-end carrying the SHA-256 computed with dc_file_sha256. Unknown offers answer file-error. The fake mode can offer a real local file through DTCHAT_TELEGRAM_FAKE_FILE and exercises the same read/hash/chunk/event path; tests/telegram_fake.py now uses a 9000-byte file, checks the offer size and SHA-256, reassembles the chunks byte-for-byte and verifies the file-end hash (25 checks, green stand-alone). The adapter links CRYPTOLIB for EVP/dc_file_sha256. The TDLib downloadFile/updateFile branch is compiled but not exercised without an account. Full build and harness follow.
2026-11-17 12:12:44 +00:00
lotherk 9e8c7cd00c dtchat: add the Join Channel dialog and the IRC join/part commands (T3.3/T4.4)
Conversation > Join Channel opens a Motif prompt (channel on IRC or room on XMPP); the OK callback calls the new join hook with the current account. accounts_run sets the hook, sends dc_adapter_join, adds the conversation (channel for IRC, group otherwise) and shows it; the adapter's conversation event updates it later. The IRC adapter now handles the join and part commands (JOIN <conv>, PART <conv> :reason) instead of ignoring them; XMPP already implemented join. Tests: tests/irc_join.py checks JOIN #new on the wire, the self-JOIN conversation event, PART #new and a clean bye (10 checks, standalone built adapter green); the UI path was verified with the fake adapter under Xvfb (DTCHAT_TEST_JOIN=#new -> 'accounts fake: join #new' and conversation #new) and the dialog screenshot build/mcde-shots/dtchat-join-dialog.png. Harness entry added (51). In-tree build follows.
2026-11-17 12:06:04 +00:00
lotherk 4057ace288 dtchat: typing, contacts and files in the Telegram/WhatsApp adapters
Telegram: updateUser becomes roster events (name and online from userStatus), the typing command sends sendChatAction (typing/cancel), file-send sends a document via inputFileLocal, an incoming messageDocument becomes a file-offer, and the fake mode emits two contacts, an offer, data/end on accept and file-sent. WhatsApp: Connected emits the address-book contacts as roster, the typing command uses SendChatPresence and incoming ChatPresence becomes typing events, file-send uploads and sends a DocumentMessage, an incoming DocumentMessage becomes a file-offer (download on accept), and the fake mode emits contacts, an offer with SHA-256, data/end on accept, a typing echo and file-sent. tests/telegram_fake.py (24 checks) and tests/whatsapp_fake.py (28 checks) cover all of it and pass with the stand-alone binaries. In-tree build and harness follow; real incoming downloads and accounts remain.
2026-11-17 11:58:27 +00:00
lotherk 3107ff3490 dtchat: draw WhatsApp pairing QRs as a bitmap (T9.1)
The Go adapter encodes every whatsmeow QR code with github.com/skip2/go-qrcode and sends both the text (qrText) and the module bitmap the UI's request dialog already understands: qr {width,height,data}, one byte per module, 1 = dark, quiet zone included, base64. The fake pairing goes through the same request function, so tests/whatsapp_fake.py now checks a square bitmap, one byte per module, both module values and the empty quiet-zone corner; all 17 checks pass with the stand-alone binary. go.mod/go.sum carry the new module. In-tree build and harness follow.
2026-11-17 11:50:28 +00:00
lotherk c2f93e1df4 dtchat: add the Telegram and WhatsApp adapter skeletons (T8.1/T9.1)
Telegram: telegram_adapter.c speaks protocol v1 with settings api_id/api_hash/phone/database, TDLib 1.8.57 through td_json (setTdlibParameters, phone/code/password as request/answer, updateNewMessage, sendMessage), states and disconnect; without TDLib it still answers hello and reports the missing library as a fatal error. Debian's versioned TDLib directories are found by configure (header and lib scan) and passed as TDLIB_CPPFLAGS/TDLIBLIB; the adapter is always built (stub without the library). WhatsApp: a Go program under whatsapp_adapter/ with go.mod/go.sum using whatsmeow from the module cache and modernc sqlite, QR pairing through whatsmeow, message events and SendMessage; without Go it is not built (MCDE_GO). Its QR is sent as qrText, which the request dialog now shows when there is no bitmap. Both adapters have DTCHAT_*_FAKE modes; tests/telegram_fake.py (15 checks) and tests/whatsapp_fake.py (13 checks) drive hello, configure, connect, the pairing request/answer, online, send echo and bye, all green stand-alone. The harness runs them when the binaries exist (50 entries with both). TDLib and golang-go were installed with apt; the WhatsApp module builds with GOPROXY=off from the cache. Real accounts, QR bitmap and files follow.
2026-11-17 11:40:59 +00:00
lotherk 4aebd2c7cd dtchat: add IRCv3 typing to the IRC adapter (T3.4)
The adapter requests the message-tags capability when the server offers it (together with sasl when a password is set) and remembers the ACK. Incoming @+typing=active|paused tags on TAGMSG or PRIVMSG become typing events with conv (channel or sender), on and who; the typing command sends @+typing=active|paused TAGMSG <conv> through the output queue, and is ignored when the capability was not negotiated. tests/irc_typing.py offers message-tags, checks the CAP REQ, sends alice's active/paused TAGMSGs, and verifies the adapter's own TAGMSG lines for typing on/off; all checks pass. The four existing IRC fake-server suites (adapter, channels, messages, reconnect) still pass with the new binary. In-tree build and harness follow.
2026-11-17 11:26:59 +00:00
lotherk fc23161a4e dtchat: verify adapter files with SHA-256 (T4.5)
The file protocol now carries the sender's SHA-256: the adapter computes it with dc_file_sha256 for an outgoing transfer, puts it into the IBB open metadata (urn:dtchat:file:0 sha256 attribute) and into file-sent, and passes the attribute of an incoming open through in file-offer. The UI stores the offered hash, hashes the part file at file-end and only renames when it matches; a mismatch removes the part file, reports 'file rejected: checksum mismatch' in the status line and the transcript, and never exposes the bytes under the final name. The fake adapter offers the correct hash in mode files and a wrong one in mode badhash. tests/xmpp_ibb.py checks the SHA-256 in the outgoing open and in the incoming offer. Verified stand-alone under Xvfb: mode files writes the 11-byte hello world, mode badhash leaves no file and no .part; the XMPP IBB suite passes with the hash checks. In-tree build and harness follow.
2026-11-17 11:13:07 +00:00
lotherk bd9c58ea0b dtchat: file transfer over XMPP IBB (T4.5)
The adapter protocol gains additive file events: file-send (conv, id, name, path), file-accept/reject/cancel commands, and file-offer/file-data/file-end/file-sent/file-reject/file-error events, with a 32 MiB limit, 4 KiB blocks and an explicit accept before data flows; docs/reference/dtchat-adapter-protocol.txt defines them. xmpp_adapter.c implements XEP-0047: outbound open (with the name/size in a urn:dtchat:file:0 child), base64 data IQs acknowledged one by one and close, then file-sent; inbound open is held until file-accept answers the IQ, data chunks become file-data events, close becomes file-end, and a reject is an IQ error. libstrophe serialises a tag's text through a separate text stanza (set_text on a named tag returns -2), which the data blocks now do. tests/xmpp_ibb.py drives a minimal server: outgoing bytes arrive unchanged, an accepted incoming file yields offer/data/end with the right size, and a rejected offer becomes an IQ error; all 26 checks pass, exit 0, no stderr. The UI file path for adapter accounts (offer dialog, accept, writing the chunks) is the next piece; the adapter itself is complete.
2026-11-17 10:46:04 +00:00
lotherk d063dc0d7b dtchat: restart the XMPP adapter after an unexpected stream end (T4.6)
conn_handler used to send a bye and exit 0 on any disconnect, which the core reads as an intentional stop. Now an unexpected end of the stream (or a failed connection) reports offline, sends no bye and exits 1: DcAdapter's existing restart policy starts the process again with backoff and the hello/configure/connect handshake repeats (the policy is covered by DtChat/test_adapter). A requested disconnect still leaves through handle_command with quitting set, bye and status 0. tests/xmpp_drop.py closes the stream after the bind and checks status 1, the offline state and no bye; xmpp_fake.py and xmpp_muc.py still pass, all with the standalone adapter. In-tree build/tests follow.
2026-11-17 10:34:28 +00:00
lotherk f0e8c668d6 dtchat: add XMPP MUC rooms (T4.4)
join sends a presence to room/nick with the http://jabber.org/protocol/muc <x/>; the room's self-presence is answered with a conversation event (kind group, title room), other occupants are reported as presence events with buddy=room/nick, groupchat messages are filed under the room with the sender's nick in from, and part sends an unavailable presence. The nick is the JID's local part. The hello caps gain muc. tests/xmpp_muc.py drives a minimal server through stream, SASL PLAIN, bind, join (checks the MUC element), self-presence, alice's presence, a groupchat message and the part; all 17 checks pass, exit 0, no stderr. UI wiring for adapter accounts is still open, as is the live test.
2026-11-17 10:02:33 +00:00
lotherk a2c4a0e4c4 dtchat: add XMPP carbons and chat states (T4.3)
After the bind the adapter enables XEP-0280 carbons and unwraps sent/received forwarded messages: a message another of our resources sent becomes a normal message event with self=true and the contact as conv, a received one self=false. XEP-0085 chat states are handled before the body: composing emits typing on, paused/active/inactive/gone off. The typing command sends composing or paused to the conversation, and dc_adapter_send_typing() puts it on the core side. tests/xmpp_fake.py checks carbons were enabled, the forwarded message (self, conv bob, text), typing on/off from bob, and that a typing command reaches the server as <composing> addressed to bob. Standalone adapter: all checks ok. The UI does not send typing for adapter accounts yet (adapter account wiring is still open), which the commit documents.
2026-11-17 09:56:18 +00:00
lotherk fed0e5010c dtchat: add the XMPP roster and presence (T4.2)
After the bind the adapter sends <presence/> and asks for the roster (iq get, jabber:iq:roster) and handles the result and pushes: every item becomes a roster event with the contact's id, name, subscription and current online state. Presence from contacts is tracked per bare JID and emitted as presence events (online with the XMPP show and status, offline, subscribe/unsubscribe); libstrophe 0.14's get_text is used for child text. The hello caps gain roster and presence, and the event shapes follow docs/reference/dtchat-adapter-protocol.txt (buddy, contact, away). tests/xmpp_fake.py now checks that the client announces itself and asks for the roster, delivers bob (name/subscription) and carol, the online-with-show/status and offline presence, and still carries messages both ways. Run against the standalone adapter: 22 checks, all ok. In-tree build pending: make mcde-host is running after the configure change.
2026-11-17 09:48:58 +00:00
lotherk 1a6572a499 dtchat: add the headless voice test (T6.7)
dtchat-headless gains --call, --audio-in FILE and --audio-out FILE: it exchanges media-key on the ready link, calls the peer, answers an incoming ring (it is a test peer, so the answer is automatic), and pumps the call from its loop: a 20 ms frame from the raw s16le 48 kHz file is encoded and sent while in the call, received frames are decoded into the output file, and call/audio events go to stdout. tests/p2p-audio.sh starts two instances (A listens and records, B connects, calls and plays tests/tone.py's 2 s 440 Hz tone), waits for both in-call, for 100 received frames, prints the CPU time of both, quits them and has tests/tone-check.py verify the recording (length within 25 percent, RMS > 500, zero crossings within 15 percent). Standalone run: A 45475, both in-call, recording 2.00 s / RMS 6339 / 441 Hz, all ok. Wired into the harness as DtChat/p2p-audio (42 entries). In-tree build pending: a foreign make userland holds the lock.
2026-11-17 08:54:05 +00:00
lotherk d634409c71 dtchat: add the XMPP adapter skeleton (T4.1)
xmpp_adapter.c speaks protocol v1 on stdio with libstrophe: hello with jid/password/resource/host/port, configure, connect (resource appended to a bare JID), xmpp_run_once in the main loop next to a non-blocking stdin, state connecting/online/offline, text messages in both directions (incoming message events, 'sent' for our own), network/stream errors, clean disconnect and bye. DTCHAT_XMPP_NO_TLS/TRUST_TLS exist for tests. libstrophe 0.14's get_text_ptr() returned NULL for a parsed body, so the adapter uses get_text() and frees it. configure checks strophe.h and libstrophe (MCDE_STROPHE); without it dtchat-xmpp is not built. tests/xmpp_fake.py runs a minimal XMPP server (stream header, SASL PLAIN, resource bind, one message each way) and the adapter passes: online after bind, incoming text and bare-JID conversation, outgoing stanza addressed and delivered, SASL payload, bye and exit 0, no stderr. In-tree build pending: a foreign release chain holds the lock (pid 141722).
2026-11-17 07:48:07 +00:00
lotherk dc44fc25a3 dtchat: add the headless peer mode (T5.7)
dtchat-headless starts the TLS listener (--listen [HOST:]PORT, port 0 prints the real port) and one reconnecting link per --peer, loads/creates the identity in --config, prints JSON events (ready, peer-online, peer-offline, message, typing, file-offer, error) and takes JSON commands on stdin (send by host:port or peer id, quit). dc_local_peer_conn() and the ack id let a link know its peer. tests/p2p.sh runs two instances over loopback: A listens, B connects, B sends, A answers by id, both quit; standalone run prints 'tests/p2p.sh: all ok'. Wired into noinst_PROGRAMS and mcde-tests.sh (expect 29 ok). make mcde-host still blocked by pid 2126511 (release/sourcesets/usb).
2026-11-16 20:43:06 +00:00