From e2ae98be759fc27ef4c999ed6870eb110fba95d8 Mon Sep 17 00:00:00 2001 From: Zhang Dingyuan Date: Thu, 25 Jul 2024 15:57:40 +0800 Subject: [PATCH] fix: not send login state for clients send state for all clients Log: --- src/daemon/Display.cpp | 22 +++++++++++++++++----- src/daemon/SingleWaylandDisplayServer.cpp | 12 ++++++++++++ src/daemon/SingleWaylandDisplayServer.h | 2 ++ 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/daemon/Display.cpp b/src/daemon/Display.cpp index b9424d4..00faefb 100644 --- a/src/daemon/Display.cpp +++ b/src/daemon/Display.cpp @@ -587,10 +587,16 @@ namespace DDM { stateConfig.Last.Session.setDefault(); stateConfig.save(); - if (m_socket) { - emit loginSucceeded(m_socket, user); - daemonApp->displayManager()->setLastSession(auth->sessionId()); + if (m_displayServerType == DisplayServerType::SingleCompositerServerType) { + auto* server = reinterpret_cast(m_displayServer); + server->onLoginSucceeded(user); + } else { + if (m_socket) { + emit loginSucceeded(m_socket, user); + daemonApp->displayManager()->setLastSession(auth->sessionId()); + } } + } m_socket = nullptr; } @@ -613,8 +619,14 @@ namespace DDM { return; m_socketServer->informationMessage(m_socket, message); - if (error == Auth::ERROR_AUTHENTICATION) - emit loginFailed(m_socket, auth->user()); + if (error == Auth::ERROR_AUTHENTICATION) { + if (m_displayServerType == DisplayServerType::SingleCompositerServerType) { + auto* server = reinterpret_cast(m_displayServer); + server->onLoginFailed(auth->user()); + } else { + emit loginFailed(m_socket, auth->user()); + } + } } void Display::slotHelperFinished(Auth::HelperExitStatus status) { diff --git a/src/daemon/SingleWaylandDisplayServer.cpp b/src/daemon/SingleWaylandDisplayServer.cpp index 087c38e..6aee8d4 100644 --- a/src/daemon/SingleWaylandDisplayServer.cpp +++ b/src/daemon/SingleWaylandDisplayServer.cpp @@ -83,3 +83,15 @@ void SingleWaylandDisplayServer::activateUser(const QString &user) { QString SingleWaylandDisplayServer::getUserWaylandSocket(const QString &user) const { return m_waylandSockets.value(user); } + +void SingleWaylandDisplayServer::onLoginFailed(const QString &user) { + for (auto greeter : m_greeterSockets) { + SocketWriter(greeter) << quint32(DaemonMessages::LoginFailed) << user; + } +} + +void SingleWaylandDisplayServer::onLoginSucceeded(const QString &user) { + for (auto greeter : m_greeterSockets) { + SocketWriter(greeter) << quint32(DaemonMessages::LoginSucceeded) << user; + } +} diff --git a/src/daemon/SingleWaylandDisplayServer.h b/src/daemon/SingleWaylandDisplayServer.h index b647f82..5ecc61b 100644 --- a/src/daemon/SingleWaylandDisplayServer.h +++ b/src/daemon/SingleWaylandDisplayServer.h @@ -26,6 +26,8 @@ class SingleWaylandDisplayServer : public DDM::WaylandDisplayServer public Q_SLOTS: void activateUser(const QString &user); QString getUserWaylandSocket(const QString &user) const; + void onLoginFailed(const QString &user); + void onLoginSucceeded(const QString &user); private: DDM::SocketServer *m_socketServer;