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.
This commit is contained in:
parent
dcf1aecafd
commit
d9d6f6ef53
4 changed files with 515 additions and 17 deletions
|
|
@ -134,7 +134,7 @@ extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> a
|
|||
cfg.outputName = "imsd-messages";
|
||||
ApplyStandardArgs(cfg, args);
|
||||
cfg.type = ConfigurationType::Executable;
|
||||
cfg.dependencies = { Core.get(), Bus.get() };
|
||||
cfg.dependencies = { Core.get(), Bus.get(), db };
|
||||
{
|
||||
std::array<fs::path, 0> ifaces = {};
|
||||
std::array<fs::path, 1> impls = { "implementations/main" };
|
||||
|
|
|
|||
Loading…
Reference in a new issue