X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Flogind-user-dbus.c;h=3673a28bd4ceb6c7eeb64427b731536d8f32422b;hp=c8d47de0e7358ea9d0b058c0150038acac4fd488;hb=57a8eca84a1eda99c8cfb63889fa300ba982cb77;hpb=da11939561b1e6eeb1131b68dbf43042fd633a05 diff --git a/src/logind-user-dbus.c b/src/logind-user-dbus.c index c8d47de0e..3673a28bd 100644 --- a/src/logind-user-dbus.c +++ b/src/logind-user-dbus.c @@ -29,6 +29,9 @@ #define BUS_USER_INTERFACE \ " \n" \ " \n" \ + " \n" \ + " \n" \ + " \n" \ " \n" \ " \n" \ " \n" \ @@ -121,7 +124,7 @@ static int bus_user_append_sessions(DBusMessageIter *i, const char *property, vo assert(property); assert(u); - if (!dbus_message_iter_open_container(i, DBUS_TYPE_ARRAY, "so", &sub)) + if (!dbus_message_iter_open_container(i, DBUS_TYPE_ARRAY, "(so)", &sub)) return -ENOMEM; LIST_FOREACH(sessions_by_user, session, u->sessions) { @@ -154,13 +157,14 @@ static int bus_user_append_sessions(DBusMessageIter *i, const char *property, vo static int bus_user_append_idle_hint(DBusMessageIter *i, const char *property, void *data) { User *u = data; - bool b; + dbus_bool_t b; assert(i); assert(property); assert(u); - b = user_get_idle_hint(u, NULL); + b = user_get_idle_hint(u, NULL) > 0; + if (!dbus_message_iter_append_basic(i, DBUS_TYPE_BOOLEAN, &b)) return -ENOMEM; @@ -249,6 +253,27 @@ static DBusHandlerResult user_message_dispatch( reply = dbus_message_new_method_return(message); if (!reply) goto oom; + } else if (dbus_message_is_method_call(message, "org.freedesktop.login1.User", "Kill")) { + int32_t signo; + + if (!dbus_message_get_args( + message, + &error, + DBUS_TYPE_INT32, &signo, + DBUS_TYPE_INVALID)) + return bus_send_error_reply(connection, message, &error, -EINVAL); + + if (signo <= 0 || signo >= _NSIG) + return bus_send_error_reply(connection, message, &error, -EINVAL); + + r = user_kill(u, signo); + if (r < 0) + return bus_send_error_reply(connection, message, NULL, r); + + reply = dbus_message_new_method_return(message); + if (!reply) + goto oom; + } else return bus_default_message_handler(connection, message, INTROSPECTION, INTERFACES_LIST, properties); @@ -353,3 +378,34 @@ finish: return r; } + +int user_send_changed(User *u, const char *properties) { + DBusMessage *m; + int r = -ENOMEM; + char *p = NULL; + + assert(u); + + if (!u->started) + return 0; + + p = user_bus_path(u); + if (!p) + return -ENOMEM; + + m = bus_properties_changed_new(p, "org.freedesktop.login1.User", properties); + if (!m) + goto finish; + + if (!dbus_connection_send(u->manager->bus, m, NULL)) + goto finish; + + r = 0; + +finish: + if (m) + dbus_message_unref(m); + free(p); + + return r; +}