From 94e16cbaba4e727af4fe40a039110c5d0f0eb467 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Wed, 14 Feb 2018 10:00:19 -0500
Subject: [PATCH 17/17] lib: don't try to update login frequency manually
The library will try to update the login frequency to 1 if the
requested user isn't finished asynchronously loading yet, but we
know they have an open session.
That no longer works, since we no longer track login-frequency
separately from the dbus proxy object.
This commit drops the code, since it's unnecessary anyway.
To be "on the safe side" we change the value returned for unloaded
users from 0 to 1. This is okay because the value is undefined
before the user is loaded anyway.
---
src/libaccountsservice/act-user-manager.c | 6 ------
src/libaccountsservice/act-user.c | 2 +-
2 files changed, 1 insertion(+), 7 deletions(-)
diff --git a/src/libaccountsservice/act-user-manager.c b/src/libaccountsservice/act-user-manager.c
index 6c6628b..6efb772 100644
--- a/src/libaccountsservice/act-user-manager.c
+++ b/src/libaccountsservice/act-user-manager.c
@@ -1663,66 +1663,60 @@ get_x11_display_for_new_session (ActUserManagerNewSession *new_session)
static void
maybe_add_new_session (ActUserManagerNewSession *new_session)
{
ActUserManager *manager;
ActUser *user;
gboolean is_ours;
manager = ACT_USER_MANAGER (new_session->manager);
is_ours = TRUE;
if (new_session->x11_display == NULL) {
g_debug ("AcUserManager: (mostly) ignoring session '%s' since it's not graphical",
new_session->id);
is_ours = FALSE;
} else if (session_is_login_window (manager, new_session->id)) {
new_session->state = ACT_USER_MANAGER_NEW_SESSION_STATE_LOADED;
unload_new_session (new_session);
return;
} else if (!session_is_on_our_seat (manager, new_session->id)) {
is_ours = FALSE;
}
user = act_user_manager_get_user_by_id (manager, new_session->uid);
if (user == NULL) {
unload_new_session (new_session);
return;
}
add_session_for_user (manager, user, new_session->id, is_ours);
-
- /* if we haven't yet gotten the login frequency
- then at least add one because the session exists */
- if (act_user_get_login_frequency (user) == 0) {
- _act_user_update_login_frequency (user, 1);
- }
}
static void
load_new_session (ActUserManager *manager,
const char *session_id)
{
ActUserManagerNewSession *new_session;
new_session = g_slice_new0 (ActUserManagerNewSession);
new_session->manager = g_object_ref (manager);
new_session->id = g_strdup (session_id);
new_session->state = ACT_USER_MANAGER_NEW_SESSION_STATE_UNLOADED + 1;
new_session->cancellable = g_cancellable_new ();
manager->priv->new_sessions = g_slist_prepend (manager->priv->new_sessions,
new_session);
load_new_session_incrementally (new_session);
}
static void
seat_session_added (GDBusProxy *seat_proxy,
const char *session_id,
ActUserManager *manager)
{
g_debug ("ActUserManager: Session added: %s", session_id);
load_new_session (manager, session_id);
}
diff --git a/src/libaccountsservice/act-user.c b/src/libaccountsservice/act-user.c
index e21c9db..bc8b7f8 100644
--- a/src/libaccountsservice/act-user.c
+++ b/src/libaccountsservice/act-user.c
@@ -705,61 +705,61 @@ act_user_get_location (ActUser *user)
*
* Returns: (transfer none): a pointer to an array of characters which must not be modified or
* freed, or %NULL.
**/
const char *
act_user_get_user_name (ActUser *user)
{
g_return_val_if_fail (ACT_IS_USER (user), NULL);
if (user->accounts_proxy == NULL)
return NULL;
return accounts_user_get_user_name (user->accounts_proxy);
}
/**
* act_user_get_login_frequency:
* @user: a #ActUser
*
* Returns the number of times @user has logged in.
*
* Returns: the login frequency
*/
int
act_user_get_login_frequency (ActUser *user)
{
g_return_val_if_fail (ACT_IS_USER (user), 0);
if (user->accounts_proxy == NULL)
- return 0;
+ return 1;
return accounts_user_get_login_frequency (user->accounts_proxy);
}
/**
* act_user_get_login_time:
* @user: a #ActUser
*
* Returns the last login time for @user.
*
* Returns: (transfer none): the login time
*/
gint64
act_user_get_login_time (ActUser *user)
{
g_return_val_if_fail (ACT_IS_USER (user), 0);
if (user->accounts_proxy == NULL)
return 0;
return accounts_user_get_login_time (user->accounts_proxy);
}
/**
* act_user_get_login_history:
* @user: a #ActUser
*
* Returns the login history for @user.
*
* Returns: (transfer none): a pointer to GVariant of type "a(xxa{sv})"
--
2.14.3