Commit graph imsd-messages/implementations
Author SHA1 Message Date
20e687452f
Ui, main: the new-conversation screen and the long-press sheets
The + opens a screen with a number field (its placeholder "Number", a
parameter of the compose field now) and Start; the number becomes a
conversation key through Number's ConversationKey, as an sms: link's
does (E.164 through the country code, a short code as digits), anything
else is refused in place. A long press on a conversation row offers to
delete the conversation, on a message to copy its text to the clipboard
or delete it; only those two have one: App tells the recogniser before
each press whether what it lands on has a long press (GestureDetector's
longPress), and without one a press held as long — on a button, a field,
a sheet's row — stays a tap at its release, so a slow finger presses the
button all the same. A sheet draws on the overlay layer over a scrim and
pushes its regions last, so they win the hit test, and the wheel scrolls
nothing under it; Escape, the back arrow and a tap outside dismiss it.
Deleting a conversation also closes its notification and drops its
draft; the + keeps the draft of the conversation it leaves, as Back
does, and so does a view that closes because its last message was
deleted. The deletes go through Sync (Erase, EraseConversation: the
commit before, which keeps a deleted text deleted). The number field's
box is drawn by its screen, as the send bar's is by the bar: the shared
field drawing paints no background of its own. Opening a conversation,
from a notification or a link, leaves the new-conversation screen and
any sheet, and the + leaves any sheet. A key whose press changed the
screen acts once: held, its repeats are not the new screen's — Enter,
which started the conversation, would type line breaks into its field,
and Escape would go on back, from a sheet through the conversation and
its draft. A sheet that asks to delete a conversation goes when a text
arrives for it: a yes would delete that text unread. A press on the
conversation's row opens no such sheet either while the row it aimed at
had not shown the text — the regions are a frame's: the press that is
down when the text arrives, and one that comes down before the next
frame is drawn, have no long press; a release before the long-press time
is still the row's tap, while the row stays under the finger.

--new and --bench-sheet put either on screen for the bench
(--bench-sheet conversation or message, each on the screen a long press
opens it over: another value is refused, and one that finds nothing to
press says so in the log), and are window flags as --screenshot is.

Tested: the screens and the sheets by the bench (--new, --bench-sheet)
and the phone step's screenshots; the deletes' logic with the commit
before, in tests/Store and tests/Sync; the press without a long press in
tests/Gesture (the timer gives no long press and a move within the slop
nothing; the release is the tap, however late; a slide off the control
is a drag); a deleted conversation's draft dropped, in tests/Edit. The
press on a row a text arrived for has no bench: none holds a finger on a
row.
2026-11-18 01:12:27 +01:00
53bc4797bc
Store, Sync, main: a deleted text stays deleted
imsd keeps a received text until an app deletes it, and a delete can be
refused (polkit, for a session that is not the active one) or time out:
the List after the next start would carry the text again and the app
would import it again (within a run Sync's own record of what it
imported keeps it out). And a deleted row is a tombstone whose bytes
stay in the file until it is rewritten.

The store gains a second table, erased.cdb: the imsd ids of received
texts the user deleted while imsd may still hold their copies, its
format held by the build as the first table's is. Erase and
EraseConversation remember the id before the row goes (a crash between
the two leaves a remembered id, never a text that comes back; a
remembering the store refuses refuses the delete), ImsdIds folds the
remembered ids in, so Sync's `known` keeps a List from importing them,
and ForgetErased drops the ids a List no longer carries — of those
remembered before that List was sent: an id remembered while it was in
flight waits for the next (FetchList's `before` snapshot). Sync's Erase
and EraseConversation go to the store; Fail and the Send continuation
check that the row still exists, so a text deleted while its Send is in
flight takes no late word, and a late answer for a deleted message finds
no row and is logged. main compacts both files at start when either
holds deleted rows or bytes an update or a delete orphaned (a state
reason replaced by another can leave some, so a start after a send may
rewrite both with nothing deleted), and opens the store again on what is
there if the rewrite failed: a deleted text's bytes leave the files at
the next start (a resident instance keeps them until then — nothing
holds a row id across the rewrite but the app itself).

Tested: tests/Store — the remembered ids across a reopen and as known, a
deleted sent text's id not remembered, the ids imsd no longer lists
forgotten, the bytes of deleted texts and forgotten ids gone after the
Compact and a reopen while the kept ones stay, a forgotten id alone
enough for a Compact, the second file private and rewritten with the
first; tests/Sync — a message deleted while it is sending (its late
answers write nothing and are logged), a received text imported,
remembered when deleted and forgotten when no longer listed, a text
signalled while a List is in flight kept by the List sent before the
delete — which forgets the id remembered before it went out — and
forgotten by the next, and a state for another client's text leaving
every message alone.
2026-11-18 01:12:27 +01:00
07c6c3e5bd
Ui, main: closing the window hides it; Activate shows it again
The resident model: a close tears the window down — a fling stops, the
device finishes its frame, the listeners let go, the frame driver and
the canvas go — and keeps the process, the store, the screens and the
bus subscription. Show builds the window again, with a conversation left
open coming back (its caret blinking again; an Open or a Show that lands
between a close and its deferred teardown keeps the window); the Wayland
display source is kept across a hide. A text that arrives for the kept
conversation while the window is hidden — from the close on, not from
its deferred teardown — stays unread and keeps its notification, like
any other conversation's; showing the window again marks it read and
closes the notification. Without a session bus, where nothing could show
the window again, a close ends the process as before. A second launch
reaches the running instance over the bus name and a notification's tap
through its ActionInvoked signal, as before.

--hide-after and --hide-every drive the cycle from the bench as closes
(without a session bus such a close ends the process, as any close does
there), and are window flags as --screenshot is.
2026-11-18 01:12:27 +01:00
8a03a4ed49
main, utilities: bench helpers and a fake imsd
--prefill types into the opened conversation's field (App::Prefill, the
bench's typing, comes with it), --send-draft taps Send 1.5 s after start
and --screenshot-after chooses the moment of the capture, so a machine
can exercise the compose path and look at the result; --prefill and
--send-draft are window flags as --screenshot is — refused beside --send
and --quit, and beside a running instance (--screenshot-after acts
through --screenshot, refused there, its seconds checked as
--quit-after's are) — and a --prefill text that is not UTF-8 is refused
as --send's is. utilities/fake-imsd.py owns net.catcrafts.IMS1 on the
session bus with the answers chosen on its command line: a registered
daemon (its GetStatus answers name the subscriber's number, --ppi; the
Messaging one and every text the SIM's operator, --operator) that
accepts sends and reports them sent (the stamp in imsd's ISO 8601 form,
at the host's offset) and delivered, a store to list and delete, texts
injected at start or delivered as unicast Received while the app runs,
the refusals (AccessDenied, NotSupported, failed sends) and a Subscribe
answered late (--subscribe-delay: the app before imsd's status is in).
It runs on the host (python3-gi), the app in the sandbox, both on the
same session bus.
2026-11-18 01:12:27 +01:00
dd1108da58
main: show the window; --screenshot and --quit-after
The executable shows the window at start unless --daemon (which
--headless and --send imply), on Activate and Open from a second launch
or a notification (of the URIs an Open carries, its first sms: link),
and on an sms: link, which opens the conversation of its first recipient
at once (Number's SmsUriRecipient: the scheme in any case, the fields
after '?' dropped, percent-escapes decoded; then ConversationKey with
the country code known at that moment — --country's, else the one imsd's
status gave once it is in, else what the number itself carries — which
takes NormalizeNumber's result as a phone number — E.164, or digits: a
short code, a national number no country code completed — and nothing
else), or just the window when it names no phone number; the
conversation remembers the address as dialled and the plan of the SIM it
was typed under, and that SIM's statuses move its key (Number's
AfterStatus, one step, applied in App::Status: another SIM's status —
another operator's, or without operators another own number's code,
Number's SameSim — changes nothing, so a SIM change leaves the key and
the plan the address was typed under; the same SIM's fills in what the
plan lacks, and the key follows from its digits to the centre's stand-in
and from any key to the own number's code once the plan has it, never
from one stand-in's key to another's and not while the code is lost, the
conversation it moves to shown at its latest message — and only while
nothing is stored under the key: a text stored before the code arrived
keeps the conversation on the key its rows carry). The shell forwards
Sync's events to the window and the notifier closes a conversation's
notification when it is opened (one closed while its Notify is on its
way goes when the answer comes). --screenshot renders one frame outside
the compositor's pacing 2.5 s after start — 600 ms later where it has to
make the window first — and saves it as a PNG before quitting, or ends
with exit 1 when no frame was captured — with a line when no window
could render it or another instance is running (a flag that acts on the
window finds none there: the run forwards nothing), and without one when
the run ended before the capture (the display gone, a close that quits);
a PNG the library cannot write is not noticed at this commit, and a
capture that throws ends the process — the verification path for a
machine without eyes, which must not depend on a desktop that repaints —
and --quit-after ends a bench on its own clock (a number of seconds its
timer can take: anything else is refused); a --send errand ended by
anything but its final state — that clock — exits 2, as it does on a
signal, its end latched before the loop stops; --screenshot beside
--send or --quit is refused, neither having a window. The window is torn
down in order before the bus client stops, and when the compositor's
connection breaks the process ends, so the next launch starts afresh. A
window the library cannot make (no display, no Vulkan driver) is logged
by Ui's Show and the start ends with exit 1, as a start without its
database does; a resident instance logs it and runs on without one, and
a later Activate or Open logs the same at once, the device's set-up
running only once.

Tested: tests/Number, the sms: links (a query, an escape, a list, the
scheme in capitals, no number), the keys of typed addresses, SameSim
(the same operator, another operator of one country, a status without
its operator, nothing known, own numbers' codes without operators) and
AfterStatus through the statuses a typed address meets: the stand-in
completing its digits while the plan learns the operator; another
stand-in, a lost code and another operator's status — its own number's
code the stand-in's or not — changing nothing; rows keeping the key
while the plan learns the code; the own number's code moving the
stand-in's key, at once or once nothing is stored; a key the own
number's code made, and its plan, staying under another SIM and under
its own SIM's stand-in; an own code that makes the stand-in's key; a
short code; --country before the operator; no operators; no address; an
international address, under another SIM and under its own; and the
address as dialled making the key the address as typed made.
2026-11-18 01:12:27 +01:00
d9d6f6ef53
main: the resident daemon mode, the send errand and one instance
The executable now runs the app without its window: it owns the session
name or forwards to the instance that does (an sms: link, --quit; --quit
beside --send is refused, the errand being no instance, and so is a link
that is not UTF-8, which D-Bus does not carry; a name request that fails
or is refused ends the run with the error's words, exit 1, nobody being
shown to run), opens the database (the executable's own Crafter.DB
dependency enters here, with its first use), connects the GDBus client
to Sync and the notifier, and runs the GLib main loop. --daemon is the
resident mode, --headless adds a log line per event for the ssh smoke
test on the phone, --session talks to imsd --session, --data-dir and
--country override the database directory and the default country code
(a country code as the ITU's length rule reads one: a key is made of the
code as it is and read by that rule, so anything else is refused). A
--daemon with no sms: link that finds the name owned ends at once
instead of forwarding an Activate: the running instance already imports
and notifies, and a forwarded Activate asks it for its window;
--headless then exits 1, having run nothing (a link and --quit are
forwarded from a --daemon as from any launch). A Subscribe, a GetStatus
or a List that failed against a present imsd is tried again every 30 s,
and so is a text Sync holds for a store that refused it; that text is
notified all the same (OnUnstored), the notification being where it
shows, and is announced as any import once its row is in.

--send sends one text to the number as dialled (stored under its
normalised key; a NUMBER or TEXT that is not UTF-8 is refused before
anything is stored, exit 2: imsd takes D-Bus strings, and GLib would put
its own text in the place of other bytes and have that sent; an empty
NUMBER is refused there too) and exits on imsd's word for the submission
— sent (0) or failed (1), which reaches it as the message's change (a
status report's word follows sent, imsd's order) — or on its own failure
(1), a store that refuses the text among them; imsd has 60 s to be ready
and to take the text, then 2 (no final state) — once it has taken it the
clock decides nothing, since imsd bounds its submission itself and ends
it with a word, and a clock of the app's would report no final state for
a text imsd goes on to send — as a SIGINT or SIGTERM after the start-up,
before a final state, is 2 (a resident instance ending on either says so
in its log: a session bus closing under it sends SIGTERM too). It is a
client of its own: it takes no instance name, since a launch that finds
the name taken forwards and exits, and it leaves imsd's stored and
signalled texts to the instance that owns the user's store; beside that
instance it needs a --data-dir of its own, the store taking one writer.
It sends once GetStatus has answered, with Sync's Send gaining a force
flag that skips the local readiness check: imsd answers a Send to its
caller, subscribed or not, so a refused or unregistered errand ends with
imsd's own reason. Its rule is Sync's SendErrand, a class over the
listener's events with no GLib in it: one Send once the status is in and
none after an end, latched before the call (Sync announces a status from
inside Send — the store's word on its write — and the loop can dispatch
one after the clock's or a signal's end); one end — the message's final
state, the store's refusal, or none on the clock (which decides until
imsd has taken the text), a signal or the loop's end; the first of them
stands. The shell drives it with its loop, its 60 s source and its log.

Tested: tests/Sync, the errand among its cases (a forced send against an
unregistered status; imsd's words reaching the listener as the message's
changes, as they come), and its rule: one Send across a status announced
from inside Send (the store's recovery, end to end on a store refused
under the file-size limit), 0 on sent, 1 on failed and on the store's
refusal, 2 on the clock before imsd's id and on a signal, the clock
deciding nothing once imsd took the text, a final state given first
standing over the clock and the loop's end after it.
2026-11-18 01:12:27 +01:00
3d635a6f9d
project: the repository skeleton
The SMS app for imsd's net.catcrafts.IMS1.Messaging interface starts
here: the licence (GPL-3.0-only), FUNDING.yml, README and AGENTS, a
project.cpp with the three build products (imsd-messages-core: std and
Crafter.DB; imsd-messages-bus: GLib; the imsd-messages executable),
their module units as stubs, the version constant, the bundled Noto Sans
font with its OFL text, and the first test. This commit is the base every
later range is reviewed against.

Tested: crafter-build builds the three products and --version answers,
crafter-build test passes the one test, lint and format --check are clean
on every text rule and on the AST rules for the eleven files without a
global module fragment; the four files that include gio/gio.h are not
parsed by the lint driver's libclang (no C++ standard library on its
include path: 'type_traits' file not found), which is a Crafter.Build
matter.
2026-10-17 23:14:00 +02:00