#include <unistd.h>
-#include "sd-messages.h"
-#include "util.h"
-#include "strv.h"
-#include "fileio.h"
-#include "conf-parser.h"
-// #include "special.h"
-#include "sleep-config.h"
+#include "alloc-util.h"
#include "bus-error.h"
#include "bus-util.h"
+#include "conf-parser.h"
+#include "formats-util.h"
#include "logind-action.h"
-// #include "formats-util.h"
#include "process-util.h"
+#include "sleep-config.h"
+//#include "special.h"
+#include "string-table.h"
#include "terminal-util.h"
+#include "user-util.h"
+
+// Additional includes needed by elogind
+#include "fd-util.h"
+#include "fileio.h"
+#include "sd-messages.h"
+#include "strv.h"
+
int manager_handle_action(
Manager *m,
[HANDLE_HYBRID_SLEEP] = "Hibernating and suspending..."
};
-/// elogind does this itself. No target table required
-#if 0
+#if 0 /// elogind does this itself. No target table required
static const char * const target_table[_HANDLE_ACTION_MAX] = {
[HANDLE_POWEROFF] = SPECIAL_POWEROFF_TARGET,
[HANDLE_REBOOT] = SPECIAL_REBOOT_TARGET,
offending->uid, strna(u),
offending->pid, strna(comm));
- warn_melody();
return -EPERM;
}
log_info("%s", message_table[handle]);
-/// elogind uses its own variant, which can use the handle directly.
-#if 0
+#if 0 /// elogind uses its own variant, which can use the handle directly.
r = bus_manager_shutdown_or_sleep_now_or_later(m, target_table[handle], inhibit_operation, &error);
#else
r = bus_manager_shutdown_or_sleep_now_or_later(m, handle, inhibit_operation, &error);
return r;
}
-static int do_sleep(const char *arg_verb) {
- _cleanup_strv_free_ char **modes = NULL, **states = NULL;
+static int do_sleep(const char *arg_verb, char **modes, char **states) {
char *arguments[] = {
NULL,
(char*) "pre",
return r;
}
-int shutdown_or_sleep(HandleAction action) {
+int shutdown_or_sleep(Manager *m, HandleAction action) {
+
+ assert(m);
+
switch (action) {
case HANDLE_POWEROFF:
return run_helper(HALT);
case HANDLE_KEXEC:
return run_helper(KEXEC);
case HANDLE_SUSPEND:
- return do_sleep("suspend");
+ return do_sleep("suspend", m->suspend_mode, m->suspend_state);
case HANDLE_HIBERNATE:
- return do_sleep("hibernate");
+ return do_sleep("hibernate", m->hibernate_mode, m->hibernate_state);
case HANDLE_HYBRID_SLEEP:
- return do_sleep("hybrid-sleep");
+ return do_sleep("hybrid-sleep", m->hybrid_sleep_mode, m->hybrid_sleep_state);
default:
return -EINVAL;
}