summaryrefslogtreecommitdiffstats
path: root/src/ck-session.c
diff options
context:
space:
mode:
authorWilliam Jon McCann <mccann@jhu.edu>2007-02-15 16:15:16 -0500
committerWilliam Jon McCann <mccann@jhu.edu>2007-02-15 16:15:16 -0500
commit497cc86462934168ab8cd379ab1130d4ef5d039b (patch)
tree97eb851d586b874606228f0807854257490ee830 /src/ck-session.c
parentcbe9b9ba1ca59d25365593fdc1a66f9ffd3183ca (diff)
add creation and idle-since times
Added GetCreationTime and GetIdleSince methods. And added the output to the list-sessions tool.
Diffstat (limited to 'src/ck-session.c')
-rw-r--r--src/ck-session.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/ck-session.c b/src/ck-session.c
index 5f44bac..b028baa 100644
--- a/src/ck-session.c
+++ b/src/ck-session.c
@@ -58,7 +58,10 @@ struct CkSessionPrivate
gboolean active;
gboolean is_local;
+ GTimeVal creation_time;
+
gboolean idle;
+ GTimeVal idle_since;
DBusGConnection *connection;
DBusGProxy *bus_proxy;
@@ -216,6 +219,10 @@ session_set_idle_internal (CkSession *session,
{
if (session->priv->idle != idle) {
session->priv->idle = idle;
+
+ /* FIXME: can we get a time from the dbus message? */
+ g_get_current_time (&session->priv->idle_since);
+
ck_debug ("Emitting idle-changed for session %s", session->priv->id);
g_signal_emit (session, signals [IDLE_CHANGED], 0);
}
@@ -223,6 +230,13 @@ session_set_idle_internal (CkSession *session,
return TRUE;
}
+/*
+ Example:
+ dbus-send --system --dest=org.freedesktop.ConsoleKit \
+ --type=method_call --print-reply --reply-timeout=2000 \
+ /org/freedesktop/ConsoleKit/Session1 \
+ org.freedesktop.ConsoleKit.Session.SetIdle boolean:TRUE
+*/
gboolean
ck_session_set_idle (CkSession *session,
gboolean idle,
@@ -283,6 +297,25 @@ ck_session_get_idle (CkSession *session,
}
gboolean
+ck_session_get_idle_since (CkSession *session,
+ DBusGMethodInvocation *context)
+{
+ char *date_str;
+
+ g_return_val_if_fail (CK_IS_SESSION (session), FALSE);
+
+ date_str = NULL;
+ if (session->priv->idle) {
+ date_str = g_time_val_to_iso8601 (&session->priv->idle_since);
+ }
+
+ dbus_g_method_return (context, date_str);
+ g_free (date_str);
+
+ return TRUE;
+}
+
+gboolean
ck_session_activate (CkSession *session,
DBusGMethodInvocation *context)
{
@@ -425,6 +458,20 @@ ck_session_get_host_name (CkSession *session,
}
gboolean
+ck_session_get_creation_time (CkSession *session,
+ char **iso8601_datetime,
+ GError **error)
+{
+ g_return_val_if_fail (CK_IS_SESSION (session), FALSE);
+
+ if (iso8601_datetime != NULL) {
+ *iso8601_datetime = g_time_val_to_iso8601 (&session->priv->creation_time);
+ }
+
+ return TRUE;
+}
+
+gboolean
ck_session_get_session_type (CkSession *session,
char **type,
GError **error)
@@ -808,6 +855,8 @@ ck_session_init (CkSession *session)
{
session->priv = CK_SESSION_GET_PRIVATE (session);
+ /* FIXME: should we have a property for this? */
+ g_get_current_time (&session->priv->creation_time);
}
static void