mirror of
https://github.com/AuxXxilium/eudev.git
synced 2025-03-09 15:14:01 +07:00
logind: unify all session lock loop
This commit is contained in:
parent
faf22b6559
commit
7ba6438631
@ -150,18 +150,6 @@ fail:
|
||||
return r;
|
||||
}
|
||||
|
||||
static int lock_sessions(Manager *m) {
|
||||
Iterator i;
|
||||
Session *session;
|
||||
|
||||
log_info("Locking sessions...");
|
||||
|
||||
HASHMAP_FOREACH(session, m->sessions, i)
|
||||
session_send_lock(session, true);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int button_handle(
|
||||
Button *b,
|
||||
InhibitWhat inhibit_key,
|
||||
@ -208,8 +196,11 @@ static int button_handle(
|
||||
}
|
||||
|
||||
/* Locking is handled differently from the rest. */
|
||||
if (handle == HANDLE_LOCK)
|
||||
return lock_sessions(b->manager);
|
||||
if (handle == HANDLE_LOCK) {
|
||||
log_info("Locking sessions...");
|
||||
session_send_lock_all(b->manager, true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inhibit_operation = handle == HANDLE_SUSPEND || handle == HANDLE_HIBERNATE || handle == HANDLE_HYBRID_SLEEP ? INHIBIT_SLEEP : INHIBIT_SHUTDOWN;
|
||||
|
||||
|
@ -1812,7 +1812,7 @@ static DBusHandlerResult manager_message_handler(
|
||||
|
||||
session = hashmap_get(m->sessions, name);
|
||||
if (!session)
|
||||
return bus_send_error_reply(connection, message, &error, -ENOENT);
|
||||
return bus_send_error_reply(connection, message, NULL, -ENOENT);
|
||||
|
||||
if (session_send_lock(session, streq(dbus_message_get_member(message), "LockSession")) < 0)
|
||||
goto oom;
|
||||
@ -1822,12 +1822,9 @@ static DBusHandlerResult manager_message_handler(
|
||||
goto oom;
|
||||
|
||||
} else if (dbus_message_is_method_call(message, "org.freedesktop.login1.Manager", "LockSessions")) {
|
||||
Session *session;
|
||||
Iterator i;
|
||||
|
||||
HASHMAP_FOREACH(session, m->sessions, i)
|
||||
if (session_send_lock(session, true) < 0)
|
||||
goto oom;
|
||||
r = session_send_lock_all(m, true);
|
||||
if (r < 0)
|
||||
bus_send_error_reply(connection, message, NULL, r);
|
||||
|
||||
reply = dbus_message_new_method_return(message);
|
||||
if (!reply)
|
||||
|
@ -570,3 +570,21 @@ int session_send_lock(Session *s, bool lock) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int session_send_lock_all(Manager *m, bool lock) {
|
||||
Session *session;
|
||||
Iterator i;
|
||||
int r = 0;
|
||||
|
||||
assert(m);
|
||||
|
||||
HASHMAP_FOREACH(session, m->sessions, i) {
|
||||
int k;
|
||||
|
||||
k = session_send_lock(session, lock);
|
||||
if (k < 0)
|
||||
r = k;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
@ -132,6 +132,7 @@ extern const DBusObjectPathVTable bus_session_vtable;
|
||||
int session_send_signal(Session *s, bool new_session);
|
||||
int session_send_changed(Session *s, const char *properties);
|
||||
int session_send_lock(Session *s, bool lock);
|
||||
int session_send_lock_all(Manager *m, bool lock);
|
||||
|
||||
const char* session_state_to_string(SessionState t);
|
||||
SessionState session_state_from_string(const char *s);
|
||||
|
Loading…
Reference in New Issue
Block a user