X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Flogin%2Flogind-button.c;h=210b889c4f987cd7998b38ac69e0578c77e98603;hb=25387573767909c96090ad22cccafc72c16542d7;hp=57e619efe690b801e80fa65cb5115afcb58a48ae;hpb=3c56cab44150ad47323970cfadfb0257c6305a74;p=elogind.git
diff --git a/src/login/logind-button.c b/src/login/logind-button.c
index 57e619efe..210b889c4 100644
--- a/src/login/logind-button.c
+++ b/src/login/logind-button.c
@@ -19,7 +19,6 @@
along with systemd; If not, see .
***/
-#include
#include
#include
#include
@@ -28,9 +27,7 @@
#include
#include "sd-messages.h"
-#include "conf-parser.h"
#include "util.h"
-#include "special.h"
#include "logind-button.h"
Button* button_new(Manager *m, const char *name) {
@@ -73,7 +70,7 @@ void button_free(Button *b) {
/* If the device has been unplugged close() returns
* ENODEV, let's ignore this, hence we don't use
* safe_close() */
- close(b->fd);
+ (void) close(b->fd);
}
free(b->name);
@@ -103,7 +100,7 @@ static void button_lid_switch_handle_action(Manager *manager, bool is_edge) {
assert(manager);
/* If we are docked, handle the lid switch differently */
- if (manager_is_docked_or_multiple_displays(manager))
+ if (manager_is_docked_or_external_displays(manager))
handle_action = manager->handle_lid_switch_docked;
else
handle_action = manager->handle_lid_switch;
@@ -159,8 +156,8 @@ static int button_dispatch(sd_event_source *s, int fd, uint32_t revents, void *u
case KEY_POWER:
case KEY_POWER2:
log_struct(LOG_INFO,
- "MESSAGE=Power key pressed.",
- MESSAGE_ID(SD_MESSAGE_POWER_KEY),
+ LOG_MESSAGE("Power key pressed."),
+ LOG_MESSAGE_ID(SD_MESSAGE_POWER_KEY),
NULL);
manager_handle_action(b->manager, INHIBIT_HANDLE_POWER_KEY, b->manager->handle_power_key, b->manager->power_key_ignore_inhibited, true);
@@ -174,8 +171,8 @@ static int button_dispatch(sd_event_source *s, int fd, uint32_t revents, void *u
case KEY_SLEEP:
log_struct(LOG_INFO,
- "MESSAGE=Suspend key pressed.",
- MESSAGE_ID(SD_MESSAGE_SUSPEND_KEY),
+ LOG_MESSAGE("Suspend key pressed."),
+ LOG_MESSAGE_ID(SD_MESSAGE_SUSPEND_KEY),
NULL);
manager_handle_action(b->manager, INHIBIT_HANDLE_SUSPEND_KEY, b->manager->handle_suspend_key, b->manager->suspend_key_ignore_inhibited, true);
@@ -183,8 +180,8 @@ static int button_dispatch(sd_event_source *s, int fd, uint32_t revents, void *u
case KEY_SUSPEND:
log_struct(LOG_INFO,
- "MESSAGE=Hibernate key pressed.",
- MESSAGE_ID(SD_MESSAGE_HIBERNATE_KEY),
+ LOG_MESSAGE("Hibernate key pressed."),
+ LOG_MESSAGE_ID(SD_MESSAGE_HIBERNATE_KEY),
NULL);
manager_handle_action(b->manager, INHIBIT_HANDLE_HIBERNATE_KEY, b->manager->handle_hibernate_key, b->manager->hibernate_key_ignore_inhibited, true);
@@ -195,8 +192,8 @@ static int button_dispatch(sd_event_source *s, int fd, uint32_t revents, void *u
if (ev.code == SW_LID) {
log_struct(LOG_INFO,
- "MESSAGE=Lid closed.",
- MESSAGE_ID(SD_MESSAGE_LID_CLOSED),
+ LOG_MESSAGE("Lid closed."),
+ LOG_MESSAGE_ID(SD_MESSAGE_LID_CLOSED),
NULL);
b->lid_closed = true;
@@ -205,8 +202,8 @@ static int button_dispatch(sd_event_source *s, int fd, uint32_t revents, void *u
} else if (ev.code == SW_DOCK) {
log_struct(LOG_INFO,
- "MESSAGE=System docked.",
- MESSAGE_ID(SD_MESSAGE_SYSTEM_DOCKED),
+ LOG_MESSAGE("System docked."),
+ LOG_MESSAGE_ID(SD_MESSAGE_SYSTEM_DOCKED),
NULL);
b->docked = true;
@@ -216,8 +213,8 @@ static int button_dispatch(sd_event_source *s, int fd, uint32_t revents, void *u
if (ev.code == SW_LID) {
log_struct(LOG_INFO,
- "MESSAGE=Lid opened.",
- MESSAGE_ID(SD_MESSAGE_LID_OPENED),
+ LOG_MESSAGE("Lid opened."),
+ LOG_MESSAGE_ID(SD_MESSAGE_LID_OPENED),
NULL);
b->lid_closed = false;
@@ -225,8 +222,8 @@ static int button_dispatch(sd_event_source *s, int fd, uint32_t revents, void *u
} else if (ev.code == SW_DOCK) {
log_struct(LOG_INFO,
- "MESSAGE=System undocked.",
- MESSAGE_ID(SD_MESSAGE_SYSTEM_UNDOCKED),
+ LOG_MESSAGE("System undocked."),
+ LOG_MESSAGE_ID(SD_MESSAGE_SYSTEM_UNDOCKED),
NULL);
b->docked = false;
@@ -247,23 +244,21 @@ int button_open(Button *b) {
b->fd = -1;
}
- p = strappenda("/dev/input/", b->name);
+ p = strjoina("/dev/input/", b->name);
b->fd = open(p, O_RDWR|O_CLOEXEC|O_NOCTTY|O_NONBLOCK);
- if (b->fd < 0) {
- log_warning("Failed to open %s: %m", b->name);
- return -errno;
- }
+ if (b->fd < 0)
+ return log_warning_errno(errno, "Failed to open %s: %m", b->name);
if (ioctl(b->fd, EVIOCGNAME(sizeof(name)), name) < 0) {
- log_error("Failed to get input name: %m");
+ log_error_errno(errno, "Failed to get input name: %m");
r = -errno;
goto fail;
}
r = sd_event_add_io(b->manager->event, &b->io_event_source, b->fd, EPOLLIN, button_dispatch, b);
if (r < 0) {
- log_error("Failed to add button event: %s", strerror(-r));
+ log_error_errno(r, "Failed to add button event: %m");
goto fail;
}