summaryrefslogtreecommitdiff
path: root/src/login/logind-session-dbus.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-06-21 16:14:53 +0200
committerLennart Poettering <lennart@poettering.net>2012-06-21 16:14:53 +0200
commit0604381b9dbef4cc498b5a77311e1da99c1430b8 (patch)
treeec766081c20d07ddd17c825d42569fbddefdcbe8 /src/login/logind-session-dbus.c
parentf1a8e221ecacea23883df57951e291a910463948 (diff)
logind: introduce a state for session, being one of online, active, closing
online = logged in active = logged in and session is in the fg closing = nominally logged out but some left-over processes still around Related to: https://bugzilla.gnome.org/show_bug.cgi?id=677556
Diffstat (limited to 'src/login/logind-session-dbus.c')
-rw-r--r--src/login/logind-session-dbus.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/login/logind-session-dbus.c b/src/login/logind-session-dbus.c
index 7f1b58072d..9103781289 100644
--- a/src/login/logind-session-dbus.c
+++ b/src/login/logind-session-dbus.c
@@ -53,12 +53,13 @@
" <property name=\"Remote\" type=\"b\" access=\"read\"/>\n" \
" <property name=\"RemoteHost\" type=\"s\" access=\"read\"/>\n" \
" <property name=\"RemoteUser\" type=\"s\" access=\"read\"/>\n" \
- " <property name=\"Service\" type=\"s\" access=\"read\"/>\n" \
+ " <property name=\"Service\" type=\"s\" access=\"read\"/>\n" \
" <property name=\"Leader\" type=\"u\" access=\"read\"/>\n" \
" <property name=\"Audit\" type=\"u\" access=\"read\"/>\n" \
" <property name=\"Type\" type=\"s\" access=\"read\"/>\n" \
- " <property name=\"Class\" type=\"s\" access=\"read\"/>\n" \
+ " <property name=\"Class\" type=\"s\" access=\"read\"/>\n" \
" <property name=\"Active\" type=\"b\" access=\"read\"/>\n" \
+ " <property name=\"State\" type=\"s\" access=\"read\"/>\n" \
" <property name=\"Controllers\" type=\"as\" access=\"read\"/>\n" \
" <property name=\"ResetControllers\" type=\"as\" access=\"read\"/>\n" \
" <property name=\"KillProcesses\" type=\"b\" access=\"read\"/>\n" \
@@ -219,6 +220,22 @@ static int bus_session_append_default_cgroup(DBusMessageIter *i, const char *pro
static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_session_append_type, session_type, SessionType);
static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_session_append_class, session_class, SessionClass);
+static int bus_session_append_state(DBusMessageIter *i, const char *property, void *data) {
+ Session *s = data;
+ const char *state;
+
+ assert(i);
+ assert(property);
+ assert(s);
+
+ state = session_state_to_string(session_get_state(s));
+
+ if (!dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, &state))
+ return -ENOMEM;
+
+ return 0;
+}
+
static int get_session_for_path(Manager *m, const char *path, Session **_s) {
Session *s;
char *id;
@@ -262,6 +279,7 @@ static const BusProperty bus_login_session_properties[] = {
{ "Type", bus_session_append_type, "s", offsetof(Session, type) },
{ "Class", bus_session_append_class, "s", offsetof(Session, class) },
{ "Active", bus_session_append_active, "b", 0 },
+ { "State", bus_session_append_state, "s", 0 },
{ "Controllers", bus_property_append_strv, "as", offsetof(Session, controllers), true },
{ "ResetControllers", bus_property_append_strv, "as", offsetof(Session, reset_controllers), true },
{ "KillProcesses", bus_property_append_bool, "b", offsetof(Session, kill_processes) },