Bus, main: start at login through the Background portal

A text that arrives while the app is not running waits in imsd until the
app is opened, and nothing notifies. Inside its flatpak the instance now
asks the desktop portal's Background interface when it starts (not for
the --send errand or --headless) to run on with the window closed and to
start `imsd-messages --daemon` at login, the mode that imports and
notifies with no window. The portal keeps the answer and writes the
login entry again at each request it grants, so a deleted entry comes
back while the background permission allows it; set to no, the
permission makes the portal refuse the request, and an entry already
written stays. Outside its own flatpak nothing is asked.

tests/Portal covers the request path the answer arrives on and the
options the request carries.
This commit is contained in:
Jorijn van der Graaf 2026-10-20 23:23:30 +02:00
commit f07a3716b3
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB
6 changed files with 221 additions and 9 deletions

View file

@ -112,7 +112,7 @@ extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> a
// imsd-messages-bus — the GLib side: imsd's dictionaries, the GDBus client
// of net.catcrafts.IMS1.Messaging, the desktop notifications, the app's
// own session-bus name and the desktop portal's appearance settings. No
// own session-bus name and the desktop portal (appearance, background). No
// window.
static auto Bus = std::make_unique<Configuration>();
Bus->path = "./";
@ -122,12 +122,13 @@ extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> a
Bus->type = ConfigurationType::LibraryStatic;
Bus->dependencies = { Core.get() };
{
std::array<fs::path, 6> ifaces = {
std::array<fs::path, 7> ifaces = {
"interfaces/ImsdMessages.Bus",
"interfaces/ImsdMessages.Bus-Variant",
"interfaces/ImsdMessages.Bus-Client",
"interfaces/ImsdMessages.Bus-Notifier",
"interfaces/ImsdMessages.Bus-Appearance",
"interfaces/ImsdMessages.Bus-Background",
"interfaces/ImsdMessages.Bus-Instance",
};
std::array<fs::path, 0> impls = {};
@ -184,11 +185,16 @@ extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> a
cfg.AddTest("Sync").Dependencies({ Core.get() });
cfg.AddTest("Gesture").Dependencies({ Core.get() });
cfg.AddTest("Edit").Dependencies({ Core.get() });
// The bus library's decoding test includes GLib's headers: the library's
// compile flags (its link flags come with the library).
TestBuilder decode = cfg.AddTest("Decode");
decode.Dependencies({ Core.get(), Bus.get() });
for (const std::string& flag : gio.compile) decode.CompileFlag(flag);
// The bus library's tests include GLib's headers: the library's compile
// flags (its link flags come with the library). Decode names the core's
// types too; Portal imports the bus library alone.
const auto busTest = [&](std::string_view name, std::vector<Configuration*> deps) {
TestBuilder test = cfg.AddTest(std::string(name));
test.Dependencies(std::move(deps));
for (const std::string& flag : gio.compile) test.CompileFlag(flag);
};
busTest("Decode", { Core.get(), Bus.get() });
busTest("Portal", { Bus.get() });
LintRules::AddRules(cfg);
return cfg;