mirror of
https://github.com/systemd/systemd.git
synced 2024-11-06 16:59:03 +03:00
login: use BUS_DEFINE_PROPERTY_GET* macros
This commit is contained in:
parent
c321885489
commit
01adcd691d
@ -277,74 +277,9 @@ static int property_get_scheduled_shutdown(
|
||||
}
|
||||
|
||||
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_handle_action, handle_action, HandleAction);
|
||||
|
||||
static int property_get_docked(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
Manager *m = userdata;
|
||||
|
||||
assert(bus);
|
||||
assert(reply);
|
||||
assert(m);
|
||||
|
||||
return sd_bus_message_append(reply, "b", manager_is_docked_or_external_displays(m));
|
||||
}
|
||||
|
||||
static int property_get_current_sessions(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
Manager *m = userdata;
|
||||
|
||||
assert(bus);
|
||||
assert(reply);
|
||||
assert(m);
|
||||
|
||||
return sd_bus_message_append(reply, "t", (uint64_t) hashmap_size(m->sessions));
|
||||
}
|
||||
|
||||
static int property_get_current_inhibitors(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
Manager *m = userdata;
|
||||
|
||||
assert(bus);
|
||||
assert(reply);
|
||||
assert(m);
|
||||
|
||||
return sd_bus_message_append(reply, "t", (uint64_t) hashmap_size(m->inhibitors));
|
||||
}
|
||||
|
||||
static int property_get_compat_user_tasks_max(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
assert(reply);
|
||||
|
||||
return sd_bus_message_append(reply, "t", CGROUP_LIMIT_MAX);
|
||||
}
|
||||
static BUS_DEFINE_PROPERTY_GET(property_get_docked, "b", Manager, manager_is_docked_or_external_displays);
|
||||
static BUS_DEFINE_PROPERTY_GET_GLOBAL(property_get_compat_user_tasks_max, "t", CGROUP_LIMIT_MAX);
|
||||
static BUS_DEFINE_PROPERTY_GET_REF(property_get_hashmap_size, "t", Hashmap *, (uint64_t) hashmap_size);
|
||||
|
||||
static int method_get_session(sd_bus_message *message, void *userdata, sd_bus_error *error) {
|
||||
_cleanup_free_ char *p = NULL;
|
||||
@ -2731,9 +2666,9 @@ const sd_bus_vtable manager_vtable[] = {
|
||||
SD_BUS_PROPERTY("RemoveIPC", "b", bus_property_get_bool, offsetof(Manager, remove_ipc), SD_BUS_VTABLE_PROPERTY_CONST),
|
||||
SD_BUS_PROPERTY("RuntimeDirectorySize", "t", bus_property_get_size, offsetof(Manager, runtime_dir_size), SD_BUS_VTABLE_PROPERTY_CONST),
|
||||
SD_BUS_PROPERTY("InhibitorsMax", "t", NULL, offsetof(Manager, inhibitors_max), SD_BUS_VTABLE_PROPERTY_CONST),
|
||||
SD_BUS_PROPERTY("NCurrentInhibitors", "t", property_get_current_inhibitors, 0, 0),
|
||||
SD_BUS_PROPERTY("NCurrentInhibitors", "t", property_get_hashmap_size, offsetof(Manager, inhibitors), 0),
|
||||
SD_BUS_PROPERTY("SessionsMax", "t", NULL, offsetof(Manager, sessions_max), SD_BUS_VTABLE_PROPERTY_CONST),
|
||||
SD_BUS_PROPERTY("NCurrentSessions", "t", property_get_current_sessions, 0, 0),
|
||||
SD_BUS_PROPERTY("NCurrentSessions", "t", property_get_hashmap_size, offsetof(Manager, sessions), 0),
|
||||
SD_BUS_PROPERTY("UserTasksMax", "t", property_get_compat_user_tasks_max, 0, SD_BUS_VTABLE_PROPERTY_CONST|SD_BUS_VTABLE_HIDDEN),
|
||||
|
||||
SD_BUS_METHOD("GetSession", "s", "o", method_get_session, SD_BUS_VTABLE_UNPRIVILEGED),
|
||||
|
@ -18,6 +18,10 @@
|
||||
#include "user-util.h"
|
||||
#include "util.h"
|
||||
|
||||
static BUS_DEFINE_PROPERTY_GET(property_get_can_multi_session, "b", Seat, seat_can_multi_session);
|
||||
static BUS_DEFINE_PROPERTY_GET(property_get_can_tty, "b", Seat, seat_can_tty);
|
||||
static BUS_DEFINE_PROPERTY_GET(property_get_can_graphical, "b", Seat, seat_can_graphical);
|
||||
|
||||
static int property_get_active_session(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
@ -41,60 +45,6 @@ static int property_get_active_session(
|
||||
return sd_bus_message_append(reply, "(so)", s->active ? s->active->id : "", p);
|
||||
}
|
||||
|
||||
static int property_get_can_multi_session(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
Seat *s = userdata;
|
||||
|
||||
assert(bus);
|
||||
assert(reply);
|
||||
assert(s);
|
||||
|
||||
return sd_bus_message_append(reply, "b", seat_can_multi_session(s));
|
||||
}
|
||||
|
||||
static int property_get_can_tty(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
Seat *s = userdata;
|
||||
|
||||
assert(bus);
|
||||
assert(reply);
|
||||
assert(s);
|
||||
|
||||
return sd_bus_message_append(reply, "b", seat_can_tty(s));
|
||||
}
|
||||
|
||||
static int property_get_can_graphical(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
Seat *s = userdata;
|
||||
|
||||
assert(bus);
|
||||
assert(reply);
|
||||
assert(s);
|
||||
|
||||
return sd_bus_message_append(reply, "b", seat_can_graphical(s));
|
||||
}
|
||||
|
||||
static int property_get_sessions(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
|
@ -86,42 +86,8 @@ static int property_get_seat(
|
||||
|
||||
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_type, session_type, SessionType);
|
||||
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_class, session_class, SessionClass);
|
||||
|
||||
static int property_get_active(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
Session *s = userdata;
|
||||
|
||||
assert(bus);
|
||||
assert(reply);
|
||||
assert(s);
|
||||
|
||||
return sd_bus_message_append(reply, "b", session_is_active(s));
|
||||
}
|
||||
|
||||
static int property_get_state(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
Session *s = userdata;
|
||||
|
||||
assert(bus);
|
||||
assert(reply);
|
||||
assert(s);
|
||||
|
||||
return sd_bus_message_append(reply, "s", session_state_to_string(session_get_state(s)));
|
||||
}
|
||||
static BUS_DEFINE_PROPERTY_GET(property_get_active, "b", Session, session_is_active);
|
||||
static BUS_DEFINE_PROPERTY_GET2(property_get_state, "s", Session, session_get_state, session_state_to_string);
|
||||
|
||||
static int property_get_idle_hint(
|
||||
sd_bus *bus,
|
||||
|
@ -17,6 +17,8 @@
|
||||
#include "strv.h"
|
||||
#include "user-util.h"
|
||||
|
||||
static BUS_DEFINE_PROPERTY_GET2(property_get_state, "s", User, user_get_state, user_state_to_string);
|
||||
|
||||
static int property_get_display(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
@ -40,24 +42,6 @@ static int property_get_display(
|
||||
return sd_bus_message_append(reply, "(so)", u->display ? u->display->id : "", p);
|
||||
}
|
||||
|
||||
static int property_get_state(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
User *u = userdata;
|
||||
|
||||
assert(bus);
|
||||
assert(reply);
|
||||
assert(u);
|
||||
|
||||
return sd_bus_message_append(reply, "s", user_state_to_string(user_get_state(u)));
|
||||
}
|
||||
|
||||
static int property_get_sessions(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
|
Loading…
Reference in New Issue
Block a user