- putchar('\n');
- }
-
- if (i->service) {
- printf("\t Service: %s", i->service);
-
- if (i->class)
- printf("; class %s", i->class);
-
- putchar('\n');
- } else if (i->class)
- printf("\t Class: %s\n", i->class);
-
- if (i->slice)
- printf("\t Slice: %s\n", i->slice);
- if (i->root_directory)
- printf("\t Root: %s\n", i->root_directory);
-
- if (i->default_control_group) {
- unsigned c;
- int output_flags =
- arg_all * OUTPUT_SHOW_ALL |
- arg_full * OUTPUT_FULL_WIDTH;
-
- printf("\t CGroup: %s\n", i->default_control_group);
-
- if (arg_transport != TRANSPORT_SSH) {
- c = columns();
- if (c > 18)
- c -= 18;
- else
- c = 0;
-
- show_cgroup_and_extra_by_spec(i->default_control_group,
- "\t\t ", c, false, &i->leader,
- i->leader > 0 ? 1 : 0,
- output_flags);
- }
- }
-}
-
-static int status_property_session(const char *name, DBusMessageIter *iter, SessionStatusInfo *i) {
- assert(name);
- assert(iter);
- assert(i);
-
- switch (dbus_message_iter_get_arg_type(iter)) {
-
- case DBUS_TYPE_STRING: {
- const char *s;
-
- dbus_message_iter_get_basic(iter, &s);
-
- if (!isempty(s)) {
- if (streq(name, "Id"))
- i->id = s;
- else if (streq(name, "Name"))
- i->name = s;
- else if (streq(name, "DefaultControlGroup"))
- i->default_control_group = s;
- else if (streq(name, "TTY"))
- i->tty = s;
- else if (streq(name, "Display"))
- i->display = s;
- else if (streq(name, "RemoteHost"))
- i->remote_host = s;
- else if (streq(name, "RemoteUser"))
- i->remote_user = s;
- else if (streq(name, "Service"))
- i->service = s;
- else if (streq(name, "Type"))
- i->type = s;
- else if (streq(name, "Class"))
- i->class = s;
- else if (streq(name, "Slice"))
- i->slice = s;
- else if (streq(name, "State"))
- i->state = s;
- }
- break;
- }
-
- case DBUS_TYPE_UINT32: {
- uint32_t u;
-
- dbus_message_iter_get_basic(iter, &u);
-
- if (streq(name, "VTNr"))
- i->vtnr = (int) u;
- else if (streq(name, "Leader"))
- i->leader = (pid_t) u;
-
- break;
- }
-
- case DBUS_TYPE_BOOLEAN: {
- dbus_bool_t b;
-
- dbus_message_iter_get_basic(iter, &b);
-
- if (streq(name, "Remote"))
- i->remote = b;
-
- break;
- }
-
- case DBUS_TYPE_UINT64: {
- uint64_t u;
-
- dbus_message_iter_get_basic(iter, &u);
-
- if (streq(name, "Timestamp"))
- i->timestamp = (usec_t) u;
-
- break;
- }
-
- case DBUS_TYPE_STRUCT: {
- DBusMessageIter sub;
-
- dbus_message_iter_recurse(iter, &sub);
-
- if (dbus_message_iter_get_arg_type(&sub) == DBUS_TYPE_UINT32 && streq(name, "User")) {
- uint32_t u;
-
- dbus_message_iter_get_basic(&sub, &u);
- i->uid = (uid_t) u;
-
- } else if (dbus_message_iter_get_arg_type(&sub) == DBUS_TYPE_STRING && streq(name, "Seat")) {
- const char *s;
-
- dbus_message_iter_get_basic(&sub, &s);
-
- if (!isempty(s))
- i->seat = s;
- }
-
- break;
- }
- }
-
- return 0;
-}
-
-static int status_property_user(const char *name, DBusMessageIter *iter, UserStatusInfo *i) {
- assert(name);
- assert(iter);
- assert(i);
-
- switch (dbus_message_iter_get_arg_type(iter)) {
-
- case DBUS_TYPE_STRING: {
- const char *s;
-
- dbus_message_iter_get_basic(iter, &s);
-
- if (!isempty(s)) {
- if (streq(name, "Name"))
- i->name = s;
- else if (streq(name, "DefaultControlGroup"))
- i->default_control_group = s;
- else if (streq(name, "Slice"))
- i->slice = s;
- else if (streq(name, "State"))
- i->state = s;
- }
- break;
- }
-
- case DBUS_TYPE_UINT32: {
- uint32_t u;
-
- dbus_message_iter_get_basic(iter, &u);
-
- if (streq(name, "UID"))
- i->uid = (uid_t) u;
-
- break;
- }
-
- case DBUS_TYPE_UINT64: {
- uint64_t u;
-
- dbus_message_iter_get_basic(iter, &u);
-
- if (streq(name, "Timestamp"))
- i->timestamp = (usec_t) u;
-
- break;
- }
-
- case DBUS_TYPE_STRUCT: {
- DBusMessageIter sub;
-
- dbus_message_iter_recurse(iter, &sub);
-
- if (dbus_message_iter_get_arg_type(&sub) == DBUS_TYPE_STRING && streq(name, "Display")) {
- const char *s;
-
- dbus_message_iter_get_basic(&sub, &s);
-
- if (!isempty(s))
- i->display = s;
- }
-
- break;
- }
-
- case DBUS_TYPE_ARRAY: {
-
- if (dbus_message_iter_get_element_type(iter) == DBUS_TYPE_STRUCT && streq(name, "Sessions")) {
- DBusMessageIter sub, sub2;
-
- dbus_message_iter_recurse(iter, &sub);
- while (dbus_message_iter_get_arg_type(&sub) == DBUS_TYPE_STRUCT) {
- const char *id;
- const char *path;
-
- dbus_message_iter_recurse(&sub, &sub2);
-
- if (bus_iter_get_basic_and_next(&sub2, DBUS_TYPE_STRING, &id, true) >= 0 &&
- bus_iter_get_basic_and_next(&sub2, DBUS_TYPE_OBJECT_PATH, &path, false) >= 0) {
- char **l;
-
- l = strv_append(i->sessions, id);
- if (!l)
- return -ENOMEM;
-
- strv_free(i->sessions);
- i->sessions = l;
- }
-
- dbus_message_iter_next(&sub);
- }
-
- return 0;
- }
- }
- }
-
- return 0;
-}
-
-static int status_property_seat(const char *name, DBusMessageIter *iter, SeatStatusInfo *i) {
- assert(name);
- assert(iter);
- assert(i);
-
- switch (dbus_message_iter_get_arg_type(iter)) {
-
- case DBUS_TYPE_STRING: {
- const char *s;
-
- dbus_message_iter_get_basic(iter, &s);
-
- if (!isempty(s)) {
- if (streq(name, "Id"))
- i->id = s;
- }
- break;
- }
-
- case DBUS_TYPE_STRUCT: {
- DBusMessageIter sub;
-
- dbus_message_iter_recurse(iter, &sub);
-
- if (dbus_message_iter_get_arg_type(&sub) == DBUS_TYPE_STRING && streq(name, "ActiveSession")) {
- const char *s;
-
- dbus_message_iter_get_basic(&sub, &s);
-
- if (!isempty(s))
- i->active_session = s;
- }
-
- break;
- }
-
- case DBUS_TYPE_ARRAY: {
-
- if (dbus_message_iter_get_element_type(iter) == DBUS_TYPE_STRUCT && streq(name, "Sessions")) {
- DBusMessageIter sub, sub2;
-
- dbus_message_iter_recurse(iter, &sub);
- while (dbus_message_iter_get_arg_type(&sub) == DBUS_TYPE_STRUCT) {
- const char *id;
- const char *path;
-
- dbus_message_iter_recurse(&sub, &sub2);
-
- if (bus_iter_get_basic_and_next(&sub2, DBUS_TYPE_STRING, &id, true) >= 0 &&
- bus_iter_get_basic_and_next(&sub2, DBUS_TYPE_OBJECT_PATH, &path, false) >= 0) {
- char **l;
-
- l = strv_append(i->sessions, id);
- if (!l)
- return -ENOMEM;
-
- strv_free(i->sessions);
- i->sessions = l;
- }
-
- dbus_message_iter_next(&sub);
- }
-
- return 0;
- }
- }
- }
-
- return 0;
-}
-
-static int status_property_machine(const char *name, DBusMessageIter *iter, MachineStatusInfo *i) {
- assert(name);
- assert(iter);
- assert(i);
-
- switch (dbus_message_iter_get_arg_type(iter)) {
-
- case DBUS_TYPE_STRING: {
- const char *s;
-
- dbus_message_iter_get_basic(iter, &s);
-
- if (!isempty(s)) {
- if (streq(name, "Name"))
- i->name = s;
- else if (streq(name, "DefaultControlGroup"))
- i->default_control_group = s;
- else if (streq(name, "Class"))
- i->class = s;
- else if (streq(name, "Service"))
- i->service = s;
- else if (streq(name, "Slice"))
- i->slice = s;
- else if (streq(name, "RootDirectory"))
- i->root_directory = s;
- }
- break;