Commit 14bb1237 authored by Ray Strode's avatar Ray Strode

user: export new Saved property

accountsservice maintains a state file for some users, if those users
have selected a specific session or language.

There's no good way, at the moment, for an application to check if a
specific user has saved state.

This commit exports the Saved property on the User object.
parent c66cee94
......@@ -838,6 +838,16 @@
</doc:doc>
</property>
<property name="Saved" type="b" access="read">
<doc:doc>
<doc:description>
<doc:para>
Whether the users account has retained state
</doc:para>
</doc:description>
</doc:doc>
</property>
<property name="Locked" type="b" access="read">
<doc:doc>
<doc:description>
......
......@@ -1214,6 +1214,7 @@ daemon_uncache_user_authorized_cb (Daemon *daemon,
remove_cache_files (user_name);
user_set_saved (user, FALSE);
user_set_cached (user, FALSE);
accounts_accounts_complete_uncache_user (NULL, context);
......@@ -1279,6 +1280,8 @@ daemon_delete_user_authorized_cb (Daemon *daemon,
remove_cache_files (pwent->pw_name);
user_set_saved (user, FALSE);
argv[0] = "/usr/sbin/userdel";
if (ud->remove_files) {
argv[1] = "-f";
......
......@@ -876,6 +876,25 @@ act_user_is_logged_in_anywhere (ActUser *user)
return user->our_sessions != NULL || user->other_sessions != NULL;
}
/**
* act_user_get_saved:
* @user: a #ActUser
*
* Returns whether or not the #ActUser account has retained state in accountsservice.
*
* Returns: %TRUE or %FALSE
*/
gboolean
act_user_get_saved (ActUser *user)
{
g_return_val_if_fail (ACT_IS_USER (user), TRUE);
if (user->accounts_proxy == NULL)
return FALSE;
return accounts_user_get_saved (user->accounts_proxy);
}
/**
* act_user_get_locked:
* @user: a #ActUser
......
......@@ -70,6 +70,7 @@ gboolean act_user_is_logged_in_anywhere (ActUser *user);
int act_user_get_login_frequency (ActUser *user);
gint64 act_user_get_login_time (ActUser *user);
const GVariant*act_user_get_login_history (ActUser *user);
gboolean act_user_get_saved (ActUser *user);
gboolean act_user_get_locked (ActUser *user);
gboolean act_user_get_automatic_login (ActUser *user);
gboolean act_user_is_system_account (ActUser *user);
......
......@@ -311,6 +311,7 @@ user_update_from_keyfile (User *user,
g_clear_pointer (&user->keyfile, g_key_file_unref);
user->keyfile = g_key_file_ref (keyfile);
user_set_cached (user, TRUE);
user_set_saved (user, TRUE);
g_object_thaw_notify (G_OBJECT (user));
}
......@@ -384,6 +385,8 @@ save_extra_data (User *user)
accounts_user_get_user_name (ACCOUNTS_USER (user)),
NULL);
g_file_set_contents (filename, data, -1, &error);
user_set_saved (user, TRUE);
}
static void
......@@ -800,6 +803,13 @@ user_set_cached (User *user,
user->cached = cached;
}
void
user_set_saved (User *user,
gboolean saved)
{
accounts_user_set_saved (ACCOUNTS_USER (user), saved);
}
static void
throw_error (GDBusMethodInvocation *context,
gint error_code,
......
......@@ -66,6 +66,8 @@ void user_update_system_account_property (User *user,
gboolean user_get_cached (User *user);
void user_set_cached (User *user,
gboolean cached);
void user_set_saved (User *user,
gboolean saved);
void user_register (User *user);
void user_unregister (User *user);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment