chiark / gitweb /
Beginnings of handling suspend/etc within logind
[elogind.git] / src / login / logind-action.c
index ae9cd4894a37273358371b39b769308b2a25c2c4..ce7f681040038f13ee6391018452cdc4e9a96925 100644 (file)
@@ -21,7 +21,6 @@
 
 #include <unistd.h>
 
-#include "sd-messages.h"
 #include "conf-parser.h"
 #include "special.h"
 #include "sleep-config.h"
@@ -46,16 +45,6 @@ int manager_handle_action(
                 [HANDLE_HYBRID_SLEEP] = "Hibernating and suspending..."
         };
 
-        static const char * const target_table[_HANDLE_ACTION_MAX] = {
-                [HANDLE_POWEROFF] = SPECIAL_POWEROFF_TARGET,
-                [HANDLE_REBOOT] = SPECIAL_REBOOT_TARGET,
-                [HANDLE_HALT] = SPECIAL_HALT_TARGET,
-                [HANDLE_KEXEC] = SPECIAL_KEXEC_TARGET,
-                [HANDLE_SUSPEND] = SPECIAL_SUSPEND_TARGET,
-                [HANDLE_HIBERNATE] = SPECIAL_HIBERNATE_TARGET,
-                [HANDLE_HYBRID_SLEEP] = SPECIAL_HYBRID_SLEEP_TARGET
-        };
-
         _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
         InhibitWhat inhibit_operation;
         Inhibitor *offending = NULL;
@@ -71,26 +60,6 @@ int manager_handle_action(
         }
 
         if (inhibit_key == INHIBIT_HANDLE_LID_SWITCH) {
-                int n;
-
-                /* If we are docked don't react to lid closing */
-                if (manager_is_docked(m)) {
-                        log_debug("Ignoring lid switch request, system is docked.");
-                        return 0;
-                }
-
-                /* If we have more than one or no displays connected,
-                 * don't react to lid closing. The no display case we
-                 * treat like this under the assumption that there is
-                 * no modern drm driver available. */
-                n = manager_count_displays(m);
-                if (n < 0)
-                        log_warning("Display counting failed: %s", strerror(-n));
-                else if (n != 1) {
-                        log_debug("Ignoring lid switch request, %i displays connected.", n);
-                        return 0;
-                }
-
                 /* If the last system suspend or startup is too close,
                  * let's not suspend for now, to give USB docking
                  * stations some time to settle so that we can
@@ -133,7 +102,7 @@ int manager_handle_action(
 
         if (!supported) {
                 log_warning("Requested operation not supported, ignoring.");
-                return -ENOTSUP;
+                return -EOPNOTSUPP;
         }
 
         if (m->action_what) {
@@ -171,7 +140,7 @@ int manager_handle_action(
 
         log_info("%s", message_table[handle]);
 
-        r = bus_manager_shutdown_or_sleep_now_or_later(m, target_table[handle], inhibit_operation, &error);
+        r = bus_manager_shutdown_or_sleep_now_or_later(m, handle, inhibit_operation, &error);
         if (r < 0) {
                 log_error("Failed to execute operation: %s", bus_error_message(&error, r));
                 return r;