dde-session-shell/9000-fix-lastLogoutUser-root-bug.patch

203 lines
8.3 KiB
Diff
Raw Normal View History

From a8a0810d6966af7c212261444fe04bb3aafc6251 Mon Sep 17 00:00:00 2001
From: uos <uos@localhost.localdomain>
Date: Wed, 5 Jul 2023 17:05:31 +0800
Subject: [PATCH] fix-lastLogoutUser-root-bug
---
src/dde-lock/lockworker.cpp | 2 -
src/lightdm-deepin-greeter/greeterworker.cpp | 2 -
src/session-widgets/authinterface.cpp | 16 --------
src/session-widgets/authinterface.h | 1 -
src/session-widgets/sessionbasemodel.cpp | 42 +++-----------------
src/session-widgets/sessionbasemodel.h | 4 --
6 files changed, 6 insertions(+), 61 deletions(-)
diff --git a/src/dde-lock/lockworker.cpp b/src/dde-lock/lockworker.cpp
index 7edeaf7..22e798b 100644
--- a/src/dde-lock/lockworker.cpp
+++ b/src/dde-lock/lockworker.cpp
@@ -81,7 +81,6 @@ void LockWorker::initConnections()
m_model->updateCurrentUser(m_lockInter->CurrentUser());
}
});
- connect(m_loginedInter, &LoginedInter::LastLogoutUserChanged, m_model, static_cast<void (SessionBaseModel::*)(const uid_t)>(&SessionBaseModel::updateLastLogoutUser));
connect(m_loginedInter, &LoginedInter::UserListChanged, m_model, &SessionBaseModel::updateLoginedUserList);
/* com.deepin.daemon.Authenticate */
connect(m_authFramework, &DeepinAuthFramework::FramworkStateChanged, m_model, &SessionBaseModel::updateFrameworkState);
@@ -199,7 +198,6 @@ void LockWorker::initData()
{
/* com.deepin.daemon.Accounts */
m_model->updateUserList(m_accountsInter->userList());
- m_model->updateLastLogoutUser(m_loginedInter->lastLogoutUser());
m_model->updateLoginedUserList(m_loginedInter->userList());
/* com.deepin.udcp.iam */
diff --git a/src/lightdm-deepin-greeter/greeterworker.cpp b/src/lightdm-deepin-greeter/greeterworker.cpp
index 915fce2..65bc331 100644
--- a/src/lightdm-deepin-greeter/greeterworker.cpp
+++ b/src/lightdm-deepin-greeter/greeterworker.cpp
@@ -120,7 +120,6 @@ void GreeterWorker::initConnections()
m_soundPlayerInter->PrepareShutdownSound(static_cast<int>(m_model->currentUser()->uid()));
}
});
- connect(m_loginedInter, &LoginedInter::LastLogoutUserChanged, m_model, static_cast<void (SessionBaseModel::*)(const uid_t)>(&SessionBaseModel::updateLastLogoutUser));
connect(m_loginedInter, &LoginedInter::UserListChanged, m_model, &SessionBaseModel::updateLoginedUserList);
/* com.deepin.daemon.Authenticate */
connect(m_authFramework, &DeepinAuthFramework::FramworkStateChanged, m_model, &SessionBaseModel::updateFrameworkState);
@@ -257,7 +256,6 @@ void GreeterWorker::initData()
/* com.deepin.daemon.Accounts */
m_model->updateUserList(m_accountsInter->userList());
- m_model->updateLastLogoutUser(m_loginedInter->lastLogoutUser());
m_model->updateLoginedUserList(m_loginedInter->userList());
/* com.deepin.udcp.iam */
diff --git a/src/session-widgets/authinterface.cpp b/src/session-widgets/authinterface.cpp
index ad8b661..38f1005 100644
--- a/src/session-widgets/authinterface.cpp
+++ b/src/session-widgets/authinterface.cpp
@@ -92,7 +92,6 @@ void AuthInterface::onUserRemove(const QString &user)
void AuthInterface::initData()
{
onUserListChanged(m_accountsInter->userList());
- onLastLogoutUserChanged(m_loginedInter->lastLogoutUser());
onLoginUserListChanged(m_loginedInter->userList());
// m_accountsInter->userList();
// m_loginedInter->lastLogoutUser();
@@ -110,24 +109,9 @@ void AuthInterface::initDBus()
connect(m_accountsInter, &AccountsInter::UserAdded, this, &AuthInterface::onUserAdded, Qt::QueuedConnection);
connect(m_accountsInter, &AccountsInter::UserDeleted, this, &AuthInterface::onUserRemove, Qt::QueuedConnection);
- connect(m_loginedInter, &LoginedInter::LastLogoutUserChanged, this, &AuthInterface::onLastLogoutUserChanged);
connect(m_loginedInter, &LoginedInter::UserListChanged, this, &AuthInterface::onLoginUserListChanged);
}
-void AuthInterface::onLastLogoutUserChanged(uint uid)
-{
- m_lastLogoutUid = uid;
-
- QList<std::shared_ptr<User>> userList = m_model->userList();
- for (auto it = userList.constBegin(); it != userList.constEnd(); ++it) {
- if ((*it)->uid() == uid) {
- m_model->updateLastLogoutUser((*it));
- return;
- }
- }
-
- m_model->updateLastLogoutUser(std::shared_ptr<User>(nullptr));
-}
void AuthInterface::onLoginUserListChanged(const QString &list)
{
diff --git a/src/session-widgets/authinterface.h b/src/session-widgets/authinterface.h
index d01afe1..3fc1fe8 100644
--- a/src/session-widgets/authinterface.h
+++ b/src/session-widgets/authinterface.h
@@ -54,7 +54,6 @@ public:
protected:
void initDBus();
void initData();
- void onLastLogoutUserChanged(uint uid);
void onLoginUserListChanged(const QString &list);
bool checkHaveDisplay(const QJsonArray &array);
diff --git a/src/session-widgets/sessionbasemodel.cpp b/src/session-widgets/sessionbasemodel.cpp
index 9593db3..f8a43de 100644
--- a/src/session-widgets/sessionbasemodel.cpp
+++ b/src/session-widgets/sessionbasemodel.cpp
@@ -31,7 +31,6 @@ SessionBaseModel::SessionBaseModel(QObject *parent)
, m_isUseWayland(QGuiApplication::platformName().startsWith("wayland", Qt::CaseInsensitive))
, m_appType(AuthCommon::None)
, m_currentUser(nullptr)
- , m_lastLogoutUser(nullptr)
, m_powerAction(PowerAction::RequireNormal)
, m_currentModeState(ModeStatus::NoStatus)
, m_authProperty {false, false, Unavailable, AuthCommon::None, AuthCommon::None, 0, "", "", ""}
@@ -385,8 +384,12 @@ bool SessionBaseModel::updateCurrentUser(const QString &userJson)
qDebug("update current user, data: %s", qPrintable(userJson));
std::shared_ptr<User> user_ptr = json2User(userJson);
- if (!user_ptr)
- user_ptr = m_lastLogoutUser ? m_lastLogoutUser : m_users->first();
+ if (!user_ptr) {
+ if (m_currentUser)
+ return false;
+
+ user_ptr = m_users->first();
+ }
return updateCurrentUser(user_ptr);
}
@@ -439,39 +442,6 @@ void SessionBaseModel::updateUserList(const QStringList &list)
}
emit userListChanged(m_users->values());
}
-
-/**
- * @brief 更新上一个登录用户
- *
- * @param uid
- */
-void SessionBaseModel::updateLastLogoutUser(const uid_t uid)
-{
- qDebug() << "SessionBaseModel::updateLastLogoutUser:" << uid;
- QList<std::shared_ptr<User>> userList = m_users->values();
- auto it = std::find_if(userList.begin(), userList.end(), [uid](std::shared_ptr<User> &user) {
- return user->uid() == uid;
- });
- if (it != userList.end()) {
- updateLastLogoutUser(it.i->t());
- }
-}
-
-/**
- * @brief 设置上一个登录的用户
- *
- * @param lastLogoutUser
- */
-void SessionBaseModel::updateLastLogoutUser(const std::shared_ptr<User> lastLogoutUser)
-{
- if (!lastLogoutUser.get() || m_lastLogoutUser == lastLogoutUser) {
- return;
- }
- qInfo() << "last logout user:" << lastLogoutUser->name() << lastLogoutUser->uid();
-
- m_lastLogoutUser = lastLogoutUser;
-}
-
/**
* @brief 更新已登录用户列表
*
diff --git a/src/session-widgets/sessionbasemodel.h b/src/session-widgets/sessionbasemodel.h
index 09e35f4..5e57249 100644
--- a/src/session-widgets/sessionbasemodel.h
+++ b/src/session-widgets/sessionbasemodel.h
@@ -70,7 +70,6 @@ public:
~SessionBaseModel() override;
inline std::shared_ptr<User> currentUser() const { return m_currentUser; }
- inline std::shared_ptr<User> lastLogoutUser() const { return m_lastLogoutUser; }
inline QList<std::shared_ptr<User>> loginedUserList() const { return m_loginedUsers->values(); }
inline QList<std::shared_ptr<User>> userList() const { return m_users->values(); }
@@ -165,8 +164,6 @@ public slots:
bool updateCurrentUser(const QString &userJson);
bool updateCurrentUser(const std::shared_ptr<User> user);
void updateUserList(const QStringList &list);
- void updateLastLogoutUser(const uid_t uid);
- void updateLastLogoutUser(const std::shared_ptr<User> lastLogoutUser);
void updateLoginedUserList(const QString &list);
/* com.deepin.daemon.Authenticate */
void updateLimitedInfo(const QString &info);
@@ -236,7 +233,6 @@ private:
AppType m_appType;
QList<std::shared_ptr<User>> m_userList;
std::shared_ptr<User> m_currentUser;
- std::shared_ptr<User> m_lastLogoutUser;
QString m_sessionKey;
PowerAction m_powerAction;
ModeStatus m_currentModeState;
--
2.27.0