chiark / gitweb /
Prep v239: A few cosmetic upgrades
[elogind.git] / src / shared / sleep-config.c
index 3cb917358c6ea214c5aa5ef3019b8e1a00babb53..77b380ca3240dc11ed90d19da48cbf1abc0bd32f 100644 (file)
@@ -363,7 +363,11 @@ static bool can_s2h(Manager *m) {
         }
 
         FOREACH_STRING(p, "suspend", "hibernate") {
+#if 0 /// elogind must transport a pointer to its managers instance
+                r = can_sleep(p);
+#else
                 r = can_sleep(m, p);
+#endif // 0
                 if (IN_SET(r, 0, -ENOSPC)) {
                         log_debug("Unable to %s system.", p);
                         return false;
@@ -378,16 +382,28 @@ static bool can_s2h(Manager *m) {
 
 #if 0 /// elogind has to ask the manager for some stuff
 int can_sleep(const char *verb) {
+        _cleanup_strv_free_ char **modes = NULL, **states = NULL;
+        int r;
 #else
 int can_sleep(Manager *m, const char *verb) {
+        assert(m);
+
+        char **modes  = streq(verb, "suspend")   ? m->suspend_mode     :
+                        streq(verb, "hibernate") ? m->hibernate_mode   :
+                                                       m->hybrid_sleep_mode;
+        char **states = streq(verb, "suspend")   ? m->suspend_state     :
+                        streq(verb, "hibernate") ? m->hibernate_state   :
+                                                   m->hybrid_sleep_state;
 #endif // 0
-        _cleanup_strv_free_ char **modes = NULL, **states = NULL;
-        int r;
 
         assert(STR_IN_SET(verb, "suspend", "hibernate", "hybrid-sleep", "suspend-then-hibernate"));
 
         if (streq(verb, "suspend-then-hibernate"))
+#if 0 /// elogind must transport a pointer to its managers instance
+                return can_s2h();
+#else
                 return can_s2h(m);
+#endif // 0
 
 #if 0 /// already parsed by elogind config
         r = parse_sleep_config(verb, &modes, &states, NULL);