return r;
}
+static int pakfire_daemon_prepare_for_shutdown(
+ sd_bus_message* message, void* data, sd_bus_error* error) {
+ struct pakfire_daemon* daemon = data;
+ int shutdown;
+ int r;
+
+ // Read the boolean value from the signal message
+ r = sd_bus_message_read(message, "b", &shutdown);
+ if (r < 0) {
+ ERROR(daemon->ctx, "Failed to parse PrepareForShutdown signal: %s\n", strerror(-r));
+ return r;
+ }
+
+ // If shutdown is true, the system is going to shut down soon.
+ // If false, the shutdown has been canceled.
+ if (shutdown) {
+ DEBUG(daemon->ctx, "Expecting the system to shut down soon...\n");
+
+ // XXX TODO
+ } else {
+ DEBUG(daemon->ctx, "Shutdown has been canceled\n");
+
+ // XXX TODO
+ }
+
+ return 0;
+}
+
static int pakfire_daemon_setup_bus(struct pakfire_daemon* daemon) {
int r;
return r;
}
+ // Attach the bus to the event loop
+ r = sd_bus_attach_event(daemon->bus, daemon->loop, SD_EVENT_PRIORITY_NORMAL);
+ if (r < 0) {
+ ERROR(daemon->ctx, "Could not attach the bus to the event loop: %s\n", strerror(-r));
+ return r;
+ }
+
+ // Add a signal match
+ r = sd_bus_match_signal(
+ daemon->bus,
+ NULL,
+
+ // Destination, Path & Interface
+ "org.freedesktop.login1",
+ "/org/freedesktop/login1",
+ "org.freedesktop.login1.Manager",
+
+ // Signal & Handler
+ "PrepareForShutdown",
+ pakfire_daemon_prepare_for_shutdown,
+ daemon
+ );
+
return 0;
}