chiark / gitweb /
Prep v239: A few cosmetic upgrades
[elogind.git] / src / login / logind-dbus.c
index 31acd57dc62641ae8ec123c3cd2c3ef1cc8f9d6d..5178dd8477f1476f5f0151e8b3568d905df1540c 100644 (file)
@@ -1979,6 +1979,9 @@ static int method_hybrid_sleep(sd_bus_message *message, void *userdata, sd_bus_e
                         m, message,
 #if 0 /// elogind uses HandleAction instead of const char* unti names
                         SPECIAL_HYBRID_SLEEP_TARGET,
+#else
+                        HANDLE_HYBRID_SLEEP,
+#endif // 0
                         INHIBIT_SLEEP,
                         "org.freedesktop.login1.hibernate",
                         "org.freedesktop.login1.hibernate-multiple-sessions",
@@ -1992,9 +1995,10 @@ static int method_suspend_then_hibernate(sd_bus_message *message, void *userdata
 
         return method_do_shutdown_or_sleep(
                         m, message,
+#if 0 /// elogind uses HandleAction instead of const char* unti names
                         SPECIAL_SUSPEND_THEN_HIBERNATE_TARGET,
 #else
-                        HANDLE_HYBRID_SLEEP,
+                        HANDLE_SUSPEND_THEN_HIBERNATE,
 #endif // 0
                         INHIBIT_SLEEP,
                         "org.freedesktop.login1.hibernate",
@@ -2363,11 +2367,11 @@ static int method_can_shutdown_or_sleep(
         blocked = manager_is_inhibited(m, w, INHIBIT_BLOCK, NULL, false, true, uid, NULL);
 
         handle = handle_action_from_string(sleep_verb);
+#if 0 /// elogind uses its own variant, which can use the handle directly.
         if (handle >= 0) {
                 const char *target;
 
                 target = manager_target_for_action(handle);
-#if 0 /// elogind does not support systemd units units. A valid handle is enough
                 if (target) {
                         _cleanup_free_ char *load_state = NULL;
 
@@ -2376,20 +2380,16 @@ static int method_can_shutdown_or_sleep(
                                 return r;
 
                         if (!streq(load_state, "loaded")) {
-#else
-                if (NULL == target) {
-#endif // 0
                                 result = "no";
                                 goto finish;
-#if 0 /// one less with elogind...
                         }
-#endif // 0
                 }
 #else
                 if ( (handle <= HANDLE_IGNORE) || (handle >= _HANDLE_ACTION_MAX) ) {
                         result = "no";
                         goto finish;
         }
+#endif // 0
 
         if (multiple_sessions) {
                 r = bus_test_polkit(message, CAP_SYS_BOOT, action_multiple_sessions, NULL, UID_INVALID, &challenge, error);
@@ -2434,7 +2434,6 @@ static int method_can_shutdown_or_sleep(
         }
 
  finish:
-
         return sd_bus_reply_method_return(message, "s", result);
 }