summaryrefslogtreecommitdiff
path: root/src/login/logind-dbus.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-04-29 18:35:10 +0200
committerLennart Poettering <lennart@poettering.net>2015-04-29 18:36:25 +0200
commit190700621f95160d364f8ec1d3e360246c41ce75 (patch)
tree783c3b43bd6fd93892fada76f5c20112a4e73d7c /src/login/logind-dbus.c
parentb53c3c2d24ed1398ee427139cd880b07bc35fa24 (diff)
sd-bus: drop bus parameter from message callback prototype
This should simplify the prototype a bit. The bus parameter is redundant in most cases, and in the few where it matters it can be derived from the message via sd_bus_message_get_bus().
Diffstat (limited to 'src/login/logind-dbus.c')
-rw-r--r--src/login/logind-dbus.c145
1 files changed, 60 insertions, 85 deletions
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index 880fbf73ca..7603b0ec72 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -243,14 +243,13 @@ static int property_get_scheduled_shutdown(
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_handle_action, handle_action, HandleAction);
-static int method_get_session(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+static int method_get_session(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_free_ char *p = NULL;
Manager *m = userdata;
const char *name;
Session *session;
int r;
- assert(bus);
assert(message);
assert(m);
@@ -269,14 +268,13 @@ static int method_get_session(sd_bus *bus, sd_bus_message *message, void *userda
return sd_bus_reply_method_return(message, "o", p);
}
-static int method_get_session_by_pid(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+static int method_get_session_by_pid(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_free_ char *p = NULL;
Session *session = NULL;
Manager *m = userdata;
pid_t pid;
int r;
- assert(bus);
assert(message);
assert(m);
@@ -306,14 +304,13 @@ static int method_get_session_by_pid(sd_bus *bus, sd_bus_message *message, void
return sd_bus_reply_method_return(message, "o", p);
}
-static int method_get_user(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+static int method_get_user(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_free_ char *p = NULL;
Manager *m = userdata;
uint32_t uid;
User *user;
int r;
- assert(bus);
assert(message);
assert(m);
@@ -332,14 +329,13 @@ static int method_get_user(sd_bus *bus, sd_bus_message *message, void *userdata,
return sd_bus_reply_method_return(message, "o", p);
}
-static int method_get_user_by_pid(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+static int method_get_user_by_pid(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_free_ char *p = NULL;
Manager *m = userdata;
User *user = NULL;
pid_t pid;
int r;
- assert(bus);
assert(message);
assert(m);
@@ -368,14 +364,13 @@ static int method_get_user_by_pid(sd_bus *bus, sd_bus_message *message, void *us
return sd_bus_reply_method_return(message, "o", p);
}
-static int method_get_seat(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+static int method_get_seat(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_free_ char *p = NULL;
Manager *m = userdata;
const char *name;
Seat *seat;
int r;
- assert(bus);
assert(message);
assert(m);
@@ -394,14 +389,13 @@ static int method_get_seat(sd_bus *bus, sd_bus_message *message, void *userdata,
return sd_bus_reply_method_return(message, "o", p);
}
-static int method_list_sessions(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+static int method_list_sessions(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
Manager *m = userdata;
Session *session;
Iterator i;
int r;
- assert(bus);
assert(message);
assert(m);
@@ -434,17 +428,16 @@ static int method_list_sessions(sd_bus *bus, sd_bus_message *message, void *user
if (r < 0)
return r;
- return sd_bus_send(bus, reply, NULL);
+ return sd_bus_send(sd_bus_message_get_bus(reply), reply, NULL);
}
-static int method_list_users(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+static int method_list_users(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
Manager *m = userdata;
User *user;
Iterator i;
int r;
- assert(bus);
assert(message);
assert(m);
@@ -475,17 +468,16 @@ static int method_list_users(sd_bus *bus, sd_bus_message *message, void *userdat
if (r < 0)
return r;
- return sd_bus_send(bus, reply, NULL);
+ return sd_bus_send(sd_bus_message_get_bus(reply), reply, NULL);
}
-static int method_list_seats(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+static int method_list_seats(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
Manager *m = userdata;
Seat *seat;
Iterator i;
int r;
- assert(bus);
assert(message);
assert(m);
@@ -513,16 +505,19 @@ static int method_list_seats(sd_bus *bus, sd_bus_message *message, void *userdat
if (r < 0)
return r;
- return sd_bus_send(bus, reply, NULL);
+ return sd_bus_send(sd_bus_message_get_bus(reply), reply, NULL);
}
-static int method_list_inhibitors(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+static int method_list_inhibitors(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
Manager *m = userdata;
Inhibitor *inhibitor;
Iterator i;
int r;
+ assert(message);
+ assert(m);
+
r = sd_bus_message_new_method_return(message, &reply);
if (r < 0)
return r;
@@ -548,10 +543,10 @@ static int method_list_inhibitors(sd_bus *bus, sd_bus_message *message, void *us
if (r < 0)
return r;
- return sd_bus_send(bus, reply, NULL);
+ return sd_bus_send(sd_bus_message_get_bus(reply), reply, NULL);
}
-static int method_create_session(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+static int method_create_session(sd_bus_message *message, void *userdata, sd_bus_error *error) {
const char *service, *type, *class, *cseat, *tty, *display, *remote_user, *remote_host, *desktop;
uint32_t uid, leader, audit_id = 0;
_cleanup_free_ char *id = NULL;
@@ -565,7 +560,6 @@ static int method_create_session(sd_bus *bus, sd_bus_message *message, void *use
SessionClass c;
int r;
- assert(bus);
assert(message);
assert(m);
@@ -841,13 +835,12 @@ fail:
return r;
}
-static int method_release_session(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+static int method_release_session(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Session *session;
const char *name;
int r;
- assert(bus);
assert(message);
assert(m);
@@ -866,13 +859,12 @@ static int method_release_session(sd_bus *bus, sd_bus_message *message, void *us
return sd_bus_reply_method_return(message, NULL);
}
-static int method_activate_session(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+static int method_activate_session(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Session *session;
const char *name;
int r;
- assert(bus);
assert(message);
assert(m);
@@ -884,17 +876,16 @@ static int method_activate_session(sd_bus *bus, sd_bus_message *message, void *u
if (r < 0)
return r;
- return bus_session_method_activate(bus, message, session, error);
+ return bus_session_method_activate(message, session, error);
}
-static int method_activate_session_on_seat(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+static int method_activate_session_on_seat(sd_bus_message *message, void *userdata, sd_bus_error *error) {
const char *session_name, *seat_name;
Manager *m = userdata;
Session *session;
Seat *seat;
int r;
- assert(bus);
assert(message);
assert(m);
@@ -923,13 +914,12 @@ static int method_activate_session_on_seat(sd_bus *bus, sd_bus_message *message,
return sd_bus_reply_method_return(message, NULL);
}
-static int method_lock_session(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+static int method_lock_session(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Session *session;
const char *name;
int r;
- assert(bus);
assert(message);
assert(m);
@@ -941,14 +931,13 @@ static int method_lock_session(sd_bus *bus, sd_bus_message *message, void *userd
if (r < 0)
return r;
- return bus_session_method_lock(bus, message, session, error);
+ return bus_session_method_lock(message, session, error);
}
-static int method_lock_sessions(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+static int method_lock_sessions(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
int r;
- assert(bus);
assert(message);
assert(m);
@@ -972,13 +961,12 @@ static int method_lock_sessions(sd_bus *bus, sd_bus_message *message, void *user
return sd_bus_reply_method_return(message, NULL);
}
-static int method_kill_session(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+static int method_kill_session(sd_bus_message *message, void *userdata, sd_bus_error *error) {
const char *name;
Manager *m = userdata;
Session *session;
int r;
- assert(bus);
assert(message);
assert(m);
@@ -990,16 +978,15 @@ static int method_kill_session(sd_bus *bus, sd_bus_message *message, void *userd
if (r < 0)
return r;
- return bus_session_method_kill(bus, message, session, error);
+ return bus_session_method_kill(message, session, error);
}
-static int method_kill_user(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+static int method_kill_user(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
uint32_t uid;
User *user;
int r;
- assert(bus);
assert(message);
assert(m);
@@ -1011,16 +998,15 @@ static int method_kill_user(sd_bus *bus, sd_bus_message *message, void *userdata
if (r < 0)
return r;
- return bus_user_method_kill(bus, message, user, error);
+ return bus_user_method_kill(message, user, error);
}
-static int method_terminate_session(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+static int method_terminate_session(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
const char *name;
Session *session;
int r;
- assert(bus);
assert(message);
assert(m);
@@ -1032,16 +1018,15 @@ static int method_terminate_session(sd_bus *bus, sd_bus_message *message, void *
if (r < 0)
return r;
- return bus_session_method_terminate(bus, message, session, error);
+ return bus_session_method_terminate(message, session, error);
}
-static int method_terminate_user(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+static int method_terminate_user(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
uint32_t uid;
User *user;
int r;
- assert(bus);
assert(message);
assert(m);
@@ -1053,16 +1038,15 @@ static int method_terminate_user(sd_bus *bus, sd_bus_message *message, void *use
if (r < 0)
return r;
- return bus_user_method_terminate(bus, message, user, error);
+ return bus_user_method_terminate(message, user, error);
}
-static int method_terminate_seat(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+static int method_terminate_seat(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
const char *name;
Seat *seat;
int r;
- assert(bus);
assert(message);
assert(m);
@@ -1074,10 +1058,10 @@ static int method_terminate_seat(sd_bus *bus, sd_bus_message *message, void *use
if (r < 0)
return r;
- return bus_seat_method_terminate(bus, message, seat, error);
+ return bus_seat_method_terminate(message, seat, error);
}
-static int method_set_user_linger(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+static int method_set_user_linger(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_free_ char *cc = NULL;
Manager *m = userdata;
int b, r;
@@ -1086,7 +1070,6 @@ static int method_set_user_linger(sd_bus *bus, sd_bus_message *message, void *us
uint32_t uid;
int interactive;
- assert(bus);
assert(message);
assert(m);
@@ -1266,12 +1249,11 @@ static int flush_devices(Manager *m) {
return trigger_device(m, NULL);
}
-static int method_attach_device(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+static int method_attach_device(sd_bus_message *message, void *userdata, sd_bus_error *error) {
const char *sysfs, *seat;
Manager *m = userdata;
int interactive, r;
- assert(bus);
assert(message);
assert(m);
@@ -1305,11 +1287,10 @@ static int method_attach_device(sd_bus *bus, sd_bus_message *message, void *user
return sd_bus_reply_method_return(message, NULL);
}
-static int method_flush_devices(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+static int method_flush_devices(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
int interactive, r;
- assert(bus);
assert(message);
assert(m);
@@ -1728,7 +1709,7 @@ static int method_do_shutdown_or_sleep(
return sd_bus_reply_method_return(message, NULL);
}
-static int method_poweroff(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+static int method_poweroff(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
return method_do_shutdown_or_sleep(
@@ -1742,7 +1723,7 @@ static int method_poweroff(sd_bus *bus, sd_bus_message *message, void *userdata,
error);
}
-static int method_reboot(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+static int method_reboot(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
return method_do_shutdown_or_sleep(
@@ -1756,7 +1737,7 @@ static int method_reboot(sd_bus *bus, sd_bus_message *message, void *userdata, s
error);
}
-static int method_suspend(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+static int method_suspend(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
return method_do_shutdown_or_sleep(
@@ -1864,7 +1845,7 @@ static int manager_scheduled_shutdown_handler(
return 0;
}
-static int method_schedule_shutdown(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+static int method_schedule_shutdown(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
_cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
const char *action_multiple_sessions = NULL;
@@ -1967,7 +1948,7 @@ static int method_schedule_shutdown(sd_bus *bus, sd_bus_message *message, void *
return sd_bus_reply_method_return(message, NULL);
}
-static int method_cancel_scheduled_shutdown(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+static int method_cancel_scheduled_shutdown(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
bool cancelled;
@@ -2002,7 +1983,7 @@ static int method_cancel_scheduled_shutdown(sd_bus *bus, sd_bus_message *message
return sd_bus_reply_method_return(message, "b", cancelled);
}
-static int method_hibernate(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+static int method_hibernate(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
return method_do_shutdown_or_sleep(
@@ -2016,7 +1997,7 @@ static int method_hibernate(sd_bus *bus, sd_bus_message *message, void *userdata
error);
}
-static int method_hybrid_sleep(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+static int method_hybrid_sleep(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
return method_do_shutdown_or_sleep(
@@ -2122,7 +2103,7 @@ static int method_can_shutdown_or_sleep(
return sd_bus_reply_method_return(message, "s", result);
}
-static int method_can_poweroff(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+static int method_can_poweroff(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
return method_can_shutdown_or_sleep(
@@ -2135,7 +2116,7 @@ static int method_can_poweroff(sd_bus *bus, sd_bus_message *message, void *userd
error);
}
-static int method_can_reboot(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+static int method_can_reboot(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
return method_can_shutdown_or_sleep(
@@ -2148,7 +2129,7 @@ static int method_can_reboot(sd_bus *bus, sd_bus_message *message, void *userdat
error);
}
-static int method_can_suspend(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+static int method_can_suspend(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
return method_can_shutdown_or_sleep(
@@ -2161,7 +2142,7 @@ static int method_can_suspend(sd_bus *bus, sd_bus_message *message, void *userda
error);
}
-static int method_can_hibernate(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+static int method_can_hibernate(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
return method_can_shutdown_or_sleep(
@@ -2174,7 +2155,7 @@ static int method_can_hibernate(sd_bus *bus, sd_bus_message *message, void *user
error);
}
-static int method_can_hybrid_sleep(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+static int method_can_hybrid_sleep(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
return method_can_shutdown_or_sleep(
@@ -2209,7 +2190,6 @@ static int property_get_reboot_to_firmware_setup(
}
static int method_set_reboot_to_firmware_setup(
- sd_bus *bus,
sd_bus_message *message,
void *userdata,
sd_bus_error *error) {
@@ -2217,7 +2197,6 @@ static int method_set_reboot_to_firmware_setup(
int b, r;
Manager *m = userdata;
- assert(bus);
assert(message);
assert(m);
@@ -2245,7 +2224,6 @@ static int method_set_reboot_to_firmware_setup(
}
static int method_can_reboot_to_firmware_setup(
- sd_bus *bus,
sd_bus_message *message,
void *userdata,
sd_bus_error *error) {
@@ -2255,7 +2233,6 @@ static int method_can_reboot_to_firmware_setup(
const char *result;
Manager *m = userdata;
- assert(bus);
assert(message);
assert(m);
@@ -2284,7 +2261,7 @@ static int method_can_reboot_to_firmware_setup(
return sd_bus_reply_method_return(message, "s", result);
}
-static int method_inhibit(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+static int method_inhibit(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
const char *who, *why, *what, *mode;
_cleanup_free_ char *id = NULL;
@@ -2297,7 +2274,6 @@ static int method_inhibit(sd_bus *bus, sd_bus_message *message, void *userdata,
uid_t uid;
int r;
- assert(bus);
assert(message);
assert(m);
@@ -2500,7 +2476,7 @@ static int session_jobs_reply(Session *s, const char *unit, const char *result)
return r;
}
-int match_job_removed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *error) {
const char *path, *result, *unit;
Manager *m = userdata;
Session *session;
@@ -2508,7 +2484,6 @@ int match_job_removed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_b
User *user;
int r;
- assert(bus);
assert(message);
assert(m);
@@ -2569,14 +2544,13 @@ int match_job_removed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_b
return 0;
}
-int match_unit_removed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+int match_unit_removed(sd_bus_message *message, void *userdata, sd_bus_error *error) {
const char *path, *unit;
Manager *m = userdata;
Session *session;
User *user;
int r;
- assert(bus);
assert(message);
assert(m);
@@ -2597,7 +2571,7 @@ int match_unit_removed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_
return 0;
}
-int match_properties_changed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+int match_properties_changed(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_free_ char *unit = NULL;
Manager *m = userdata;
const char *path;
@@ -2605,7 +2579,6 @@ int match_properties_changed(sd_bus *bus, sd_bus_message *message, void *userdat
User *user;
int r;
- assert(bus);
assert(message);
assert(m);
@@ -2630,13 +2603,14 @@ int match_properties_changed(sd_bus *bus, sd_bus_message *message, void *userdat
return 0;
}
-int match_reloading(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+int match_reloading(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Session *session;
Iterator i;
int b, r;
- assert(bus);
+ assert(message);
+ assert(m);
r = sd_bus_message_read(message, "b", &b);
if (r < 0) {
@@ -2656,16 +2630,17 @@ int match_reloading(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus
return 0;
}
-int match_name_owner_changed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
+int match_name_owner_changed(sd_bus_message *message, void *userdata, sd_bus_error *error) {
const char *name, *old, *new;
Manager *m = userdata;
Session *session;
Iterator i;
int r;
-
-
char *key;
+ assert(message);
+ assert(m);
+
r = sd_bus_message_read(message, "sss", &name, &old, &new);
if (r < 0) {
bus_log_parse_error(r);