Skip to content

Commit

Permalink
logind: convert to the new scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
keszybz committed May 5, 2020
1 parent a3b7cf5 commit c2b178d
Show file tree
Hide file tree
Showing 10 changed files with 247 additions and 243 deletions.
11 changes: 10 additions & 1 deletion src/login/logind-dbus.c
Expand Up @@ -3322,7 +3322,7 @@ static int method_inhibit(sd_bus_message *message, void *userdata, sd_bus_error
return r;
}

const sd_bus_vtable manager_vtable[] = {
static const sd_bus_vtable manager_vtable[] = {
SD_BUS_VTABLE_START(0),

SD_BUS_WRITABLE_PROPERTY("EnableWallMessages", "b", NULL, NULL, offsetof(Manager, enable_wall_messages), 0),
Expand Down Expand Up @@ -3754,6 +3754,15 @@ const sd_bus_vtable manager_vtable[] = {
SD_BUS_VTABLE_END
};

const BusObjectImplementation manager_object = {
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager",
.vtables = BUS_VTABLES(manager_vtable),
.children = BUS_IMPLEMENTATIONS(&seat_object,
&session_object,
&user_object),
};

static int session_jobs_reply(Session *s, uint32_t jid, const char *unit, const char *result) {
assert(s);
assert(unit);
Expand Down
3 changes: 3 additions & 0 deletions src/login/logind-dbus.h
Expand Up @@ -3,6 +3,7 @@

#include "sd-bus.h"

#include "bus-util.h"
#include "logind.h"
#include "logind-session.h"
#include "logind-user.h"
Expand All @@ -29,3 +30,5 @@ int manager_abandon_scope(Manager *manager, const char *scope, sd_bus_error *err
int manager_kill_unit(Manager *manager, const char *unit, KillWho who, int signo, sd_bus_error *error);
int manager_unit_is_active(Manager *manager, const char *unit, sd_bus_error *error);
int manager_job_is_active(Manager *manager, const char *path, sd_bus_error *error);

extern const BusObjectImplementation manager_object;
79 changes: 43 additions & 36 deletions src/login/logind-seat-dbus.c
Expand Up @@ -291,41 +291,7 @@ static int method_switch_to_previous(sd_bus_message *message, void *userdata, sd
return sd_bus_reply_method_return(message, NULL);
}

const sd_bus_vtable seat_vtable[] = {
SD_BUS_VTABLE_START(0),

SD_BUS_PROPERTY("Id", "s", NULL, offsetof(Seat, id), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("ActiveSession", "(so)", property_get_active_session, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("CanMultiSession", "b", property_get_const_true, 0, SD_BUS_VTABLE_PROPERTY_CONST|SD_BUS_VTABLE_HIDDEN),
SD_BUS_PROPERTY("CanTTY", "b", property_get_can_tty, 0, SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("CanGraphical", "b", property_get_can_graphical, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("Sessions", "a(so)", property_get_sessions, 0, 0),
SD_BUS_PROPERTY("IdleHint", "b", property_get_idle_hint, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("IdleSinceHint", "t", property_get_idle_since_hint, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("IdleSinceHintMonotonic", "t", property_get_idle_since_hint, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),

SD_BUS_METHOD("Terminate", NULL, NULL, bus_seat_method_terminate, SD_BUS_VTABLE_UNPRIVILEGED),

SD_BUS_METHOD_WITH_NAMES("ActivateSession",
"s",
SD_BUS_PARAM(session_id),
NULL,,
method_activate_session,
SD_BUS_VTABLE_UNPRIVILEGED),
SD_BUS_METHOD_WITH_NAMES("SwitchTo",
"u",
SD_BUS_PARAM(vtnr),
NULL,,
method_switch_to,
SD_BUS_VTABLE_UNPRIVILEGED),

SD_BUS_METHOD("SwitchToNext", NULL, NULL, method_switch_to_next, SD_BUS_VTABLE_UNPRIVILEGED),
SD_BUS_METHOD("SwitchToPrevious", NULL, NULL, method_switch_to_previous, SD_BUS_VTABLE_UNPRIVILEGED),

SD_BUS_VTABLE_END
};

int seat_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error) {
static int seat_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error) {
_cleanup_free_ char *e = NULL;
sd_bus_message *message;
Manager *m = userdata;
Expand Down Expand Up @@ -373,7 +339,7 @@ char *seat_bus_path(Seat *s) {
return strjoin("/org/freedesktop/login1/seat/", t);
}

int seat_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error) {
static int seat_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error) {
_cleanup_strv_free_ char **l = NULL;
sd_bus_message *message;
Manager *m = userdata;
Expand Down Expand Up @@ -478,3 +444,44 @@ int seat_send_changed(Seat *s, const char *properties, ...) {

return sd_bus_emit_properties_changed_strv(s->manager->bus, p, "org.freedesktop.login1.Seat", l);
}

static const sd_bus_vtable seat_vtable[] = {
SD_BUS_VTABLE_START(0),

SD_BUS_PROPERTY("Id", "s", NULL, offsetof(Seat, id), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("ActiveSession", "(so)", property_get_active_session, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("CanMultiSession", "b", property_get_const_true, 0, SD_BUS_VTABLE_PROPERTY_CONST|SD_BUS_VTABLE_HIDDEN),
SD_BUS_PROPERTY("CanTTY", "b", property_get_can_tty, 0, SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("CanGraphical", "b", property_get_can_graphical, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("Sessions", "a(so)", property_get_sessions, 0, 0),
SD_BUS_PROPERTY("IdleHint", "b", property_get_idle_hint, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("IdleSinceHint", "t", property_get_idle_since_hint, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("IdleSinceHintMonotonic", "t", property_get_idle_since_hint, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),

SD_BUS_METHOD("Terminate", NULL, NULL, bus_seat_method_terminate, SD_BUS_VTABLE_UNPRIVILEGED),

SD_BUS_METHOD_WITH_NAMES("ActivateSession",
"s",
SD_BUS_PARAM(session_id),
NULL,,
method_activate_session,
SD_BUS_VTABLE_UNPRIVILEGED),
SD_BUS_METHOD_WITH_NAMES("SwitchTo",
"u",
SD_BUS_PARAM(vtnr),
NULL,,
method_switch_to,
SD_BUS_VTABLE_UNPRIVILEGED),

SD_BUS_METHOD("SwitchToNext", NULL, NULL, method_switch_to_next, SD_BUS_VTABLE_UNPRIVILEGED),
SD_BUS_METHOD("SwitchToPrevious", NULL, NULL, method_switch_to_previous, SD_BUS_VTABLE_UNPRIVILEGED),

SD_BUS_VTABLE_END
};

const BusObjectImplementation seat_object = {
"/org/freedesktop/login1/seat",
"org.freedesktop.login1.Seat",
.fallback_vtables = BUS_FALLBACK_VTABLES({seat_vtable, seat_object_find}),
.node_enumerator = seat_node_enumerator,
};
5 changes: 2 additions & 3 deletions src/login/logind-seat-dbus.h
Expand Up @@ -4,11 +4,10 @@
#include "sd-bus.h"

#include "logind-seat.h"
#include "bus-util.h"

extern const sd_bus_vtable seat_vtable[];
extern const BusObjectImplementation seat_object;

int seat_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error);
int seat_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error);
char *seat_bus_path(Seat *s);

int seat_send_signal(Seat *s, bool new_seat);
Expand Down

0 comments on commit c2b178d

Please sign in to comment.